From 2f321316013bdc6d45d07ff5477b53cbc3c5de05 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 15 Oct 2017 10:22:06 +0200 Subject: [PATCH] Replace our `WeakMap` polyfill with the one from core-js Since we're already using core-js elsewhere in `compatibility.js`, we can reduce the amount of code we need to maintain ourselves. https://github.com/zloirock/core-js#weakmap --- src/shared/compatibility.js | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index b7d587349..9d2f45125 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -1195,35 +1195,7 @@ PDFJS.compatibilityChecked = true; if (globalScope.WeakMap) { return; } - - var id = 0; - function WeakMap() { - this.id = '$weakmap' + (id++); - } - WeakMap.prototype = { - has(obj) { - if ((typeof obj !== 'object' && typeof obj !== 'function') || - obj === null) { - return false; - } - return !!Object.getOwnPropertyDescriptor(obj, this.id); - }, - get(obj) { - return this.has(obj) ? obj[this.id] : undefined; - }, - set(obj, value) { - Object.defineProperty(obj, this.id, { - value, - enumerable: false, - configurable: true, - }); - }, - delete(obj) { - delete obj[this.id]; - }, - }; - - globalScope.WeakMap = WeakMap; + globalScope.WeakMap = require('core-js/fn/weak-map'); })(); // Polyfill from https://github.com/Polymer/URL