From 289a1849c45464cb23bdcaf42c3653515945fc17 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 15 Dec 2019 21:31:30 -0500 Subject: [PATCH] Add _createPopupInternal to return both popup and new ID --- ext/fg/js/popup-proxy-host.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 697c8077..157097de 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -52,25 +52,13 @@ class PopupProxyHost { } createPopup(parentId, depth) { - 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; - } - ++this._nextId; - const popup = new Popup(id, depth, this._frameIdPromise); - if (parent !== null) { - popup.parent = parent; - parent.child = popup; - } - this._popups.set(id, popup); - return popup; + return this._createPopupInternal(parentId, depth).popup; } // Message handlers async _onApiCreateNestedPopup(parentId) { - return this.createPopup(parentId, 0).id; + return this._createPopupInternal(parentId, 0).id; } async _onApiSetOptions(id, options) { @@ -117,6 +105,22 @@ class PopupProxyHost { // Private functions + _createPopupInternal(parentId, depth) { + 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; + } + ++this._nextId; + const popup = new Popup(id, depth, this._frameIdPromise); + if (parent !== null) { + popup.parent = parent; + parent.child = popup; + } + this._popups.set(id, popup); + return {popup, id}; + } + _getPopup(id) { const popup = this._popups.get(id); if (typeof popup === 'undefined') {