From 9fa20ad8c5cede72655b32b3a31e6aa2cbc28374 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 9 Feb 2021 12:01:07 +0100 Subject: [PATCH] [GENERIC viewer] Skip the `iframe`-case when checking if the `container` div, on `BaseViewer`-instances, is absolutely positioned (PR 12354 follow-up) Given that `getComputedStyle` only works on visible elements, the result of PR 12354 is that if the viewer is placed in a *hidden* `iframe` the viewer will now be broken. This obviously wasn't the intention of that PR, hence I believe that we should limit the `position: absolute;` check slightly to avoid this. --- web/base_viewer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index 0ad5257b2..3c6f169f5 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -172,7 +172,10 @@ class BaseViewer { throw new Error("Invalid `container` and/or `viewer` option."); } - if (getComputedStyle(this.container).position !== "absolute") { + if ( + this.container.offsetParent && + getComputedStyle(this.container).position !== "absolute" + ) { throw new Error("The `container` must be absolutely positioned."); } }