Don't use/assign popup private fields without using "this" (#635)

This commit is contained in:
toasted-nutbread 2020-07-03 11:54:51 -04:00 committed by GitHub
parent af4dc49074
commit 0279d00274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,8 +122,8 @@ class Popup {
} }
async containsPoint(x, y) { async containsPoint(x, y) {
for (let popup = this; popup !== null && popup.isVisibleSync(); popup = popup._child) { for (let popup = this; popup !== null && popup.isVisibleSync(); popup = popup.child) {
const rect = popup._frame.getBoundingClientRect(); const rect = popup.getFrameRect();
if (x >= rect.left && y >= rect.top && x < rect.right && y < rect.bottom) { if (x >= rect.left && y >= rect.top && x < rect.right && y < rect.bottom) {
return true; return true;
} }
@ -166,11 +166,15 @@ class Popup {
if (this._parent !== null) { if (this._parent !== null) {
throw new Error('Popup already has a parent'); throw new Error('Popup already has a parent');
} }
if (parent._child !== null) { parent.setChild(this);
throw new Error('Cannot parent popup to another popup which already has a child');
}
this._parent = parent; this._parent = parent;
parent._child = this; }
setChild(popup) {
if (this._child !== null) {
throw new Error('Popup already has a child');
}
this._child = popup;
} }
isVisibleSync() { isVisibleSync() {