Skip to content

Commit

Permalink
Merge pull request #12354 from Snuffleupagus/BaseViewer-container-pos…
Browse files Browse the repository at this point in the history
…ition-absolute

Ensure that the `container` div, on `BaseViewer`-instances, is absolutely positioned
  • Loading branch information
timvandermeij authored Sep 9, 2020
2 parents e51e9d1 + c27dcf2 commit 82dede0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 82dede0

Please sign in to comment.