[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.
This commit is contained in:
Jonas Jenwald 2021-02-09 12:01:07 +01:00
parent 884c65c602
commit 9fa20ad8c5

View File

@ -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.");
}
}