mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Use object-spread when dispatching events in the toolbars
This format is more compact, and should be available in all browsers that we currently support; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#browser_compatibility
This commit is contained in:
parent
8b7e44682c
commit
51113c17e9
2 changed files with 2 additions and 12 deletions
|
@ -203,11 +203,7 @@ class SecondaryToolbar {
|
||||||
for (const { element, eventName, close, eventDetails } of this.buttons) {
|
for (const { element, eventName, close, eventDetails } of this.buttons) {
|
||||||
element.addEventListener("click", evt => {
|
element.addEventListener("click", evt => {
|
||||||
if (eventName !== null) {
|
if (eventName !== null) {
|
||||||
const details = { source: this };
|
this.eventBus.dispatch(eventName, { source: this, ...eventDetails });
|
||||||
for (const property in eventDetails) {
|
|
||||||
details[property] = eventDetails[property];
|
|
||||||
}
|
|
||||||
this.eventBus.dispatch(eventName, details);
|
|
||||||
}
|
}
|
||||||
if (close) {
|
if (close) {
|
||||||
this.close();
|
this.close();
|
||||||
|
|
|
@ -150,13 +150,7 @@ class Toolbar {
|
||||||
for (const { element, eventName, eventDetails } of this.buttons) {
|
for (const { element, eventName, eventDetails } of this.buttons) {
|
||||||
element.addEventListener("click", evt => {
|
element.addEventListener("click", evt => {
|
||||||
if (eventName !== null) {
|
if (eventName !== null) {
|
||||||
const details = { source: this };
|
this.eventBus.dispatch(eventName, { source: this, ...eventDetails });
|
||||||
if (eventDetails) {
|
|
||||||
for (const property in eventDetails) {
|
|
||||||
details[property] = eventDetails[property];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.eventBus.dispatch(eventName, details);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue