change Popup.children to Popup.child

This commit is contained in:
siikamiika 2019-09-01 19:47:33 +03:00 committed by toasted-nutbread
parent 97be029dee
commit 2df9a7f977
3 changed files with 6 additions and 16 deletions

View File

@ -57,7 +57,7 @@ class PopupProxyHost {
const popup = new Popup(id, depth, this.frameIdPromise); const popup = new Popup(id, depth, this.frameIdPromise);
if (parent !== null) { if (parent !== null) {
popup.parent = parent; popup.parent = parent;
parent.children.push(popup); parent.child = popup;
} }
this.popups[id] = popup; this.popups[id] = popup;
return popup; return popup;

View File

@ -24,7 +24,7 @@ class PopupProxy {
this.id = null; this.id = null;
this.idPromise = null; this.idPromise = null;
this.parent = null; this.parent = null;
this.children = []; this.child = null;
this.depth = 0; this.depth = 0;
this.container = null; this.container = null;

View File

@ -24,7 +24,7 @@ class Popup {
this.frameIdPromise = frameIdPromise; this.frameIdPromise = frameIdPromise;
this.frameId = null; this.frameId = null;
this.parent = null; this.parent = null;
this.children = []; this.child = null;
this.container = document.createElement('iframe'); this.container = document.createElement('iframe');
this.container.id = 'yomichan-float'; this.container.id = 'yomichan-float';
this.container.addEventListener('mousedown', e => e.stopPropagation()); this.container.addEventListener('mousedown', e => e.stopPropagation());
@ -212,19 +212,9 @@ class Popup {
} }
hideChildren() { hideChildren() {
if (this.children.length === 0) { // recursively hides all children
return; if (this.child && !this.child.isContainerHidden()) {
} this.child.hide();
const targets = this.children.slice(0);
while (targets.length > 0) {
const target = targets.shift();
if (target.isContainerHidden()) { continue; }
target.hide();
for (const child of target.children) {
targets.push(child);
}
} }
} }