Skip to content

Commit

Permalink
Merge pull request mozilla#12321 from Snuffleupagus/BaseViewer-valida…
Browse files Browse the repository at this point in the history
…te-viewer-option

Ensure that the `viewer` property, on `BaseViewer`-instances, is a valid div-element (issue 12320)
  • Loading branch information
timvandermeij committed Sep 3, 2020
2 parents 84da13b + 89f6bb0 commit 3be9c65
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ class BaseViewer {

this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild;

if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
!(
this.container instanceof HTMLDivElement &&
this.viewer instanceof HTMLDivElement
)
) {
throw new Error("Invalid `container` and/or `viewer` option.");
}
this.eventBus = options.eventBus;
this.linkService = options.linkService || new SimpleLinkService();
this.downloadManager = options.downloadManager || null;
Expand Down

0 comments on commit 3be9c65

Please sign in to comment.