Skip to content

Commit

Permalink
Ensure that the viewer property, on BaseViewer-instances, is a va…
Browse files Browse the repository at this point in the history
…lid div-element (issue 12320)

This should help prevent future issues, caused by the user omitting the `viewer` option and/or providing an incorrect `container` option, when initializing a `BaseViewer`-instance.
  • Loading branch information
Snuffleupagus committed Sep 3, 2020
1 parent 84da13b commit abd6f43
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ class BaseViewer {

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

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

0 comments on commit abd6f43

Please sign in to comment.