default to [0, 0] when sourceFrame is not found

This commit is contained in:
siikamiika 2020-04-04 16:48:35 +03:00
parent c171503d77
commit 559033f0a6
2 changed files with 7 additions and 3 deletions

View File

@ -80,7 +80,10 @@ class FrameOffsetForwarder {
sourceFrame = frame; sourceFrame = frame;
break; break;
} }
if (sourceFrame === null) { return; } if (sourceFrame === null) {
this._forwardFrameOffsetOrigin(null, uniqueId);
return;
}
const [forwardedX, forwardedY] = offset; const [forwardedX, forwardedY] = offset;
const {x, y} = sourceFrame.getBoundingClientRect(); const {x, y} = sourceFrame.getBoundingClientRect();

View File

@ -138,7 +138,8 @@ class PopupProxy {
this._frameOffsetPromise = this._getFrameOffset(); this._frameOffsetPromise = this._getFrameOffset();
if (firstRun) { if (firstRun) {
try { try {
this._frameOffset = await this._frameOffsetPromise; const offset = await this._frameOffsetPromise;
this._frameOffset = offset !== null ? offset : [0, 0];
this._frameOffsetUpdatedAt = Date.now(); this._frameOffsetUpdatedAt = Date.now();
} catch (e) { } catch (e) {
console.error(e); console.error(e);
@ -146,7 +147,7 @@ class PopupProxy {
this._frameOffsetPromise = null; this._frameOffsetPromise = null;
} else { } else {
this._frameOffsetPromise.then((offset) => { this._frameOffsetPromise.then((offset) => {
this._frameOffset = offset; this._frameOffset = offset !== null ? offset : [0, 0];
this._frameOffsetUpdatedAt = Date.now(); this._frameOffsetUpdatedAt = Date.now();
this._frameOffsetPromise = null; this._frameOffsetPromise = null;
}, (e) => { }, (e) => {