From 88ac8f4ead5f1d23923dd6f526f585c3c38d05a0 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 15 Dec 2019 16:58:44 -0500 Subject: [PATCH] Update PopupProxyHost.popups to use a Map --- ext/fg/js/popup-proxy-host.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index de182afe..f2e2f5d0 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -19,7 +19,7 @@ class PopupProxyHost { constructor() { - this.popups = {}; + this.popups = new Map(); this.nextId = 0; this.apiReceiver = null; this.frameIdPromise = null; @@ -50,7 +50,7 @@ class PopupProxyHost { } createPopup(parentId, depth) { - const parent = (typeof parentId === 'string' && hasOwn(this.popups, parentId) ? this.popups[parentId] : null); + const parent = (typeof parentId === 'string' && this.popups.has(parentId) ? this.popups.get(parentId) : null); const id = `${this.nextId}`; if (parent !== null) { depth = parent.depth + 1; @@ -61,7 +61,7 @@ class PopupProxyHost { popup.parent = parent; parent.child = popup; } - this.popups[id] = popup; + this.popups.set(id, popup); return popup; } @@ -70,11 +70,11 @@ class PopupProxyHost { } getPopup(id) { - if (!hasOwn(this.popups, id)) { + const popup = this.popups.get(id); + if (typeof popup === 'undefined') { throw new Error('Invalid popup ID'); } - - return this.popups[id]; + return popup; } jsonRectToDOMRect(popup, jsonRect) {