mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Ensure that the empty dictionary won't be accidentally modified
Currently there's nothing that prevents modification of the `Dict.empty` primitive, which obviously needs to be *truly* empty to prevent any future (hard to find) bugs.
This commit is contained in:
parent
b0c7a74a0c
commit
a531c98cd2
1 changed files with 8 additions and 1 deletions
|
@ -171,7 +171,14 @@ var Dict = (function DictClosure() {
|
|||
},
|
||||
};
|
||||
|
||||
Dict.empty = new Dict(null);
|
||||
Dict.empty = (function () {
|
||||
const emptyDict = new Dict(null);
|
||||
|
||||
emptyDict.set = (key, value) => {
|
||||
unreachable("Should not call `set` on the empty dictionary.");
|
||||
};
|
||||
return emptyDict;
|
||||
})();
|
||||
|
||||
Dict.merge = function ({ xref, dictArray, mergeSubDicts = false }) {
|
||||
const mergedDict = new Dict(xref);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue