Add setParent to popup

This commit is contained in:
toasted-nutbread 2019-12-15 21:40:06 -05:00
parent 30e13354b3
commit 7c68490d2e
2 changed files with 15 additions and 2 deletions

View File

@ -114,8 +114,7 @@ class PopupProxyHost {
++this._nextId;
const popup = new Popup(id, depth, this._frameIdPromise);
if (parent !== null) {
popup.parent = parent;
parent.child = popup;
popup.setParent(parent);
}
this._popups.set(id, popup);
return {popup, id};

View File

@ -113,6 +113,20 @@ class Popup {
// Popup-only public functions
setParent(parent) {
if (parent === null) {
throw new Error('Cannot set popup parent to null');
}
if (this.parent !== null) {
throw new Error('Popup already has a parent');
}
if (parent.child !== null) {
throw new Error('Cannot parent popup to another popup which already has a child');
}
this.parent = parent;
parent.child = this;
}
isVisible() {
return this.isInjected && (this.visibleOverride !== null ? this.visibleOverride : this.visible);
}