Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use the deprecated CustomEvent.initCustomEvent method anymore #16336

Merged
merged 1 commit into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions web/event_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
}
}
Expand Down
28 changes: 17 additions & 11 deletions web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 5 additions & 2 deletions web/pdf_print_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down