1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Fix the inconsistent return types for Dict.{get, getAsync}

Having these methods fallback to returning `null` in only *one* particular case seems outright wrong, since a "falsy" value will thus be handled incorrectly.
The only reason that this hasn't caused issues in practice is that there's only one call-site passing in three keys, and in that case we're trying to read a font file where falling back to `null` isn't a problem.
This commit is contained in:
Jonas Jenwald 2019-09-23 11:41:19 +02:00
parent 9596d702a9
commit 7f18c57c12
2 changed files with 4 additions and 6 deletions

View file

@ -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;
@ -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);