aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-02 12:58:24 -0400
committerGitHub <noreply@github.com>2020-05-02 12:58:24 -0400
commit8a368aaddc62024b04419970736bb07dabe796bc (patch)
treee35eab56e1a925dce3a4d31b3caab8dc406f0013 /ext/fg/js
parent401fe9f8d027fe71f25d2f591f316781e1e0a436 (diff)
Don't parent the popup frame to elements which cause unload (#488)
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/popup.js18
1 files changed, 17 insertions, 1 deletions
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;