Skip to content

Commit

Permalink
Merge pull request #11171 from Snuffleupagus/Dict-get-consistent-retu…
Browse files Browse the repository at this point in the history
…rn-type

Fix the inconsistent return types for `Dict.{get, getAsync}`
  • Loading branch information
timvandermeij authored Sep 23, 2019
2 parents 9596d70 + 7f18c57 commit 44f4cd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/core/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var Dict = (function DictClosure() {
key2 in this._map || typeof key3 === 'undefined') {
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
}
value = this._map[key3] || null;
value = this._map[key3];
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
},

Expand All @@ -114,7 +114,7 @@ var Dict = (function DictClosure() {
}
return Promise.resolve(value);
}
value = this._map[key3] || null;
value = this._map[key3];
if (xref) {
return xref.fetchIfRefAsync(value, suppressEncryption);
}
Expand Down
6 changes: 2 additions & 4 deletions test/unit/primitives_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ describe('primitives', function() {
expect(dict.get()).toBeUndefined();
expect(dict.get('Prev')).toBeUndefined();
expect(dict.get('Decode', 'D')).toBeUndefined();

// Note that the getter with three arguments breaks the pattern here.
expect(dict.get('FontFile', 'FontFile2', 'FontFile3')).toBeNull();
expect(dict.get('FontFile', 'FontFile2', 'FontFile3')).toBeUndefined();
};

var emptyDict, dictWithSizeKey, dictWithManyKeys;
Expand Down Expand Up @@ -145,7 +143,7 @@ describe('primitives', function() {

Promise.all(keyPromises).then(function (values) {
expect(values[0]).toBeUndefined();
expect(values[1]).toBeNull();
expect(values[1]).toBeUndefined();
done();
}).catch(function (reason) {
done.fail(reason);
Expand Down

0 comments on commit 44f4cd5

Please sign in to comment.