From d9bf571f5c49e1cac9054cf6b7acfc0b5b719876 Mon Sep 17 00:00:00 2001 From: Pascal Drinkuth Date: Sat, 15 Apr 2023 14:51:21 +0200 Subject: [PATCH] Use `CustomEvent` when dispatching the "webviewerloaded" event According to MDN, see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/initCustomEvent, using initCustomEvent() is deprecated. --- web/viewer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/viewer.js b/web/viewer.js index 7a8dabf53..6e2a2e16a 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -179,9 +179,12 @@ function webViewerLoad() { // Give custom implementations of the default viewer a simpler way to // set various `AppOptions`, by dispatching an event once all viewer // files are loaded but *before* the viewer initialization has run. - const event = document.createEvent("CustomEvent"); - event.initCustomEvent("webviewerloaded", true, true, { - source: window, + const event = new CustomEvent("webviewerloaded", { + bubbles: true, + cancelable: true, + detail: { + source: window, + }, }); try { // Attempt to dispatch the event at the embedding `document`,