Fixes WeakMap polyfill (and improves PDFWorker port check).
This commit is contained in:
parent
e5ac64f81f
commit
631e6bebff
@ -1232,7 +1232,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
let pdfWorkerPorts = new WeakMap();
|
let pdfWorkerPorts = new WeakMap();
|
||||||
|
|
||||||
function PDFWorker(name, port) {
|
function PDFWorker(name, port) {
|
||||||
if (pdfWorkerPorts.has(port)) {
|
if (port && pdfWorkerPorts.has(port)) {
|
||||||
throw new Error('Cannot use more than one PDFWorker per port');
|
throw new Error('Cannot use more than one PDFWorker per port');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,10 +1176,14 @@ PDFJS.compatibilityChecked = true;
|
|||||||
}
|
}
|
||||||
WeakMap.prototype = {
|
WeakMap.prototype = {
|
||||||
has(obj) {
|
has(obj) {
|
||||||
|
if ((typeof obj !== 'object' && typeof obj !== 'function') ||
|
||||||
|
obj === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return !!Object.getOwnPropertyDescriptor(obj, this.id);
|
return !!Object.getOwnPropertyDescriptor(obj, this.id);
|
||||||
},
|
},
|
||||||
get(obj, defaultValue) {
|
get(obj) {
|
||||||
return this.has(obj) ? obj[this.id] : defaultValue;
|
return this.has(obj) ? obj[this.id] : undefined;
|
||||||
},
|
},
|
||||||
set(obj, value) {
|
set(obj, value) {
|
||||||
Object.defineProperty(obj, this.id, {
|
Object.defineProperty(obj, this.id, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user