Merge pull request #12354 from Snuffleupagus/BaseViewer-container-position-absolute

Ensure that the `container` div, on `BaseViewer`-instances, is absolutely positioned
This commit is contained in:
Tim van der Meij 2020-09-09 22:32:36 +02:00 committed by GitHub
commit 82dede0458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,14 +145,21 @@ class BaseViewer {
this.viewer = options.viewer || options.container.firstElementChild;
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
!(
this.container instanceof HTMLDivElement &&
this.viewer instanceof HTMLDivElement
)
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
throw new Error("Invalid `container` and/or `viewer` option.");
if (
!(
this.container instanceof HTMLDivElement &&
this.viewer instanceof HTMLDivElement
)
) {
throw new Error("Invalid `container` and/or `viewer` option.");
}
if (getComputedStyle(this.container).position !== "absolute") {
throw new Error("The `container` must be absolutely positioned.");
}
}
this.eventBus = options.eventBus;
this.linkService = options.linkService || new SimpleLinkService();