aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup-proxy-host.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-15 21:31:30 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-16 19:54:41 -0500
commit289a1849c45464cb23bdcaf42c3653515945fc17 (patch)
treec74b040901821ffe50bed481a62136db36b03031 /ext/fg/js/popup-proxy-host.js
parent41fadfd0a9efd414bc41fab95b72deffac0d77fc (diff)
Add _createPopupInternal to return both popup and new ID
Diffstat (limited to 'ext/fg/js/popup-proxy-host.js')
-rw-r--r--ext/fg/js/popup-proxy-host.js32
1 files 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') {