diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-15 16:58:44 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-16 19:54:41 -0500 |
commit | 88ac8f4ead5f1d23923dd6f526f585c3c38d05a0 (patch) | |
tree | 488459c7518d571b545a7e9313e5c0d9450d9fef | |
parent | 8efbf9bd0dfc112689e0ccd8238a8cd0af5baec3 (diff) |
Update PopupProxyHost.popups to use a Map
-rw-r--r-- | ext/fg/js/popup-proxy-host.js | 12 |
1 files 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) { |