Fixes WeakMap polyfill (and improves PDFWorker port check).

This commit is contained in:
Yury Delendik 2017-06-13 09:16:12 -05:00
parent e5ac64f81f
commit 631e6bebff
2 changed files with 7 additions and 3 deletions

View File

@ -1232,7 +1232,7 @@ var PDFWorker = (function PDFWorkerClosure() {
let pdfWorkerPorts = new WeakMap();
function PDFWorker(name, port) {
if (pdfWorkerPorts.has(port)) {
if (port && pdfWorkerPorts.has(port)) {
throw new Error('Cannot use more than one PDFWorker per port');
}

View File

@ -1176,10 +1176,14 @@ PDFJS.compatibilityChecked = true;
}
WeakMap.prototype = {
has(obj) {
if ((typeof obj !== 'object' && typeof obj !== 'function') ||
obj === null) {
return false;
}
return !!Object.getOwnPropertyDescriptor(obj, this.id);
},
get(obj, defaultValue) {
return this.has(obj) ? obj[this.id] : defaultValue;
get(obj) {
return this.has(obj) ? obj[this.id] : undefined;
},
set(obj, value) {
Object.defineProperty(obj, this.id, {