From f23dba1c10134b7a83998ac537df62042c237e4c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 31 Oct 2018 18:15:23 +0100 Subject: [PATCH] Change `canvasInRendering` to a `WeakSet` instead of a `WeakMap` Note how nowhere in the code `canvasInRendering.get()` is ever called, and that this structure is really only used to store references to `` DOM elements. The reason for this being a `WeakMap` is probably because at the time we weren't using `core-js` polyfills yet, and since there already existed a manually implemented `WeakMap` polyfill it was probably simpler to use that. --- src/display/api.js | 4 ++-- src/shared/compatibility.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index ca192afe46d5d..1cf958848cf1e 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2365,7 +2365,7 @@ var RenderTask = (function RenderTaskClosure() { * @ignore */ var InternalRenderTask = (function InternalRenderTaskClosure() { - let canvasInRendering = new WeakMap(); + let canvasInRendering = new WeakSet(); function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory, webGLContext, @@ -2408,7 +2408,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.'); } - canvasInRendering.set(this._canvas, this); + canvasInRendering.add(this._canvas); } if (this._pdfBug && globalScope.StepperManager && diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index 66eff05915037..ff99f9b150624 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -187,6 +187,14 @@ const hasDOM = typeof window === 'object' && typeof document === 'object'; globalScope.WeakMap = require('core-js/fn/weak-map'); })(); +// Support: IE11 +(function checkWeakSet() { + if (globalScope.WeakSet) { + return; + } + globalScope.WeakSet = require('core-js/fn/weak-set'); +})(); + // Provides support for String.codePointAt in legacy browsers. // Support: IE11. (function checkStringCodePointAt() {