From 8a368aaddc62024b04419970736bb07dabe796bc Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 2 May 2020 12:58:24 -0400 Subject: Don't parent the popup frame to elements which cause unload (#488) --- ext/fg/js/popup.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index e735431b..00658f58 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -281,7 +281,7 @@ class Popup { } _onFullscreenChanged() { - const parent = (DOM.getFullscreenElement() || document.body || null); + const parent = this._getFrameParentElement(); if (parent !== null && this._container.parentNode !== parent) { parent.appendChild(this._container); } @@ -375,6 +375,22 @@ class Popup { contentWindow.postMessage({action, params, token}, this._targetOrigin); } + _getFrameParentElement() { + const defaultParent = document.body; + const fullscreenElement = DOM.getFullscreenElement(); + if (fullscreenElement === null || fullscreenElement.shadowRoot) { + return defaultParent; + } + + switch (fullscreenElement.nodeName.toUpperCase()) { + case 'IFRAME': + case 'FRAME': + return defaultParent; + } + + return fullscreenElement; + } + static _getPositionForHorizontalText(elementRect, width, height, viewport, offsetScale, optionsGeneral) { const preferBelow = (optionsGeneral.popupHorizontalTextPosition === 'below'); const horizontalOffset = optionsGeneral.popupHorizontalOffset * offsetScale; -- cgit v1.2.3