-
Notifications
You must be signed in to change notification settings - Fork 27k
Closed
Labels
P2The issue is important to a large percentage of users, with a workaroundThe issue is important to a large percentage of users, with a workaroundarea: zonesIssues related to zone.jsIssues related to zone.jshotlist: google
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/zone.js.
Is this a regression?
AFAICT, it has always been like this.
Description
W3C event handlers are supposed to be called regardless if one of them throws an exception.
However when global callback handling is used (default), if any of the registered event handlers result in an unhandled exception, execution of all remaining handlers is aborted. This represents a significant and hard-to-detect breakage in event handling just from loading ZoneJS.
angular/packages/zone.js/lib/common/events.ts
Lines 150 to 155 in 51bb922
| for (let i = 0; i < copyTasks.length; i++) { | |
| if (event && (event as any)[IMMEDIATE_PROPAGATION_SYMBOL] === true) { | |
| break; | |
| } | |
| invokeTask(copyTasks[i], target, event); | |
| } |
🔬 Minimal Reproduction
When run w/o ZoneJS, clicking the button prints both click 1 and click 2.
When run with ZoneJS loaded, only click 1 is printed.
(function() {
const btn = document.body.appendChild(document.createElement('button'));
btn.textContent = 'Click me';
btn.addEventListener('click', () => {
console.log('click 1');
throw new Error();
});
btn.addEventListener('click', () => {
console.log('click 2');
});
})()Metadata
Metadata
Assignees
Labels
P2The issue is important to a large percentage of users, with a workaroundThe issue is important to a large percentage of users, with a workaroundarea: zonesIssues related to zone.jsIssues related to zone.jshotlist: google