Add _createPopupInternal to return both popup and new ID

This commit is contained in:
toasted-nutbread 2019-12-15 21:31:30 -05:00
parent 41fadfd0a9
commit 289a1849c4

View File

@ -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') {