Merge pull request #12321 from Snuffleupagus/BaseViewer-validate-viewer-option

Ensure that the `viewer` property, on `BaseViewer`-instances, is a valid div-element (issue 12320)
This commit is contained in:
Tim van der Meij 2020-09-03 22:11:23 +02:00 committed by GitHub
commit 3be9c65f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,6 +143,17 @@ class BaseViewer {
this.container = options.container; this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild; 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.eventBus = options.eventBus;
this.linkService = options.linkService || new SimpleLinkService(); this.linkService = options.linkService || new SimpleLinkService();
this.downloadManager = options.downloadManager || null; this.downloadManager = options.downloadManager || null;