Merge pull request #16336 from timvandermeij/custom-event
Don't use the deprecated `CustomEvent.initCustomEvent` method anymore
This commit is contained in:
commit
28f96d2ac2
@ -172,7 +172,7 @@ class AutomationEventBus extends EventBus {
|
||||
}
|
||||
super.dispatch(eventName, data);
|
||||
|
||||
const details = Object.create(null);
|
||||
const detail = Object.create(null);
|
||||
if (data) {
|
||||
for (const key in data) {
|
||||
const value = data[key];
|
||||
@ -182,11 +182,14 @@ class AutomationEventBus extends EventBus {
|
||||
}
|
||||
continue; // Ignore the `source` property.
|
||||
}
|
||||
details[key] = value;
|
||||
detail[key] = value;
|
||||
}
|
||||
}
|
||||
const event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent(eventName, true, true, details);
|
||||
const event = new CustomEvent(eventName, {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
detail,
|
||||
});
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
|
@ -40,11 +40,14 @@ class FirefoxCom {
|
||||
const request = document.createTextNode("");
|
||||
document.documentElement.append(request);
|
||||
|
||||
const sender = document.createEvent("CustomEvent");
|
||||
sender.initCustomEvent("pdf.js.message", true, false, {
|
||||
action,
|
||||
data,
|
||||
sync: true,
|
||||
const sender = new CustomEvent("pdf.js.message", {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
detail: {
|
||||
action,
|
||||
data,
|
||||
sync: true,
|
||||
},
|
||||
});
|
||||
request.dispatchEvent(sender);
|
||||
const response = sender.detail.response;
|
||||
@ -88,12 +91,15 @@ class FirefoxCom {
|
||||
}
|
||||
document.documentElement.append(request);
|
||||
|
||||
const sender = document.createEvent("CustomEvent");
|
||||
sender.initCustomEvent("pdf.js.message", true, false, {
|
||||
action,
|
||||
data,
|
||||
sync: false,
|
||||
responseExpected: !!callback,
|
||||
const sender = new CustomEvent("pdf.js.message", {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
detail: {
|
||||
action,
|
||||
data,
|
||||
sync: false,
|
||||
responseExpected: !!callback,
|
||||
},
|
||||
});
|
||||
request.dispatchEvent(sender);
|
||||
}
|
||||
|
@ -273,8 +273,11 @@ window.print = function () {
|
||||
};
|
||||
|
||||
function dispatchEvent(eventType) {
|
||||
const event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent(eventType, false, false, "custom");
|
||||
const event = new CustomEvent(eventType, {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
detail: "custom",
|
||||
});
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user