(context: unknown, event: Event, isCapture: boolean)
| 252 | }; |
| 253 | |
| 254 | function globalCallback(context: unknown, event: Event, isCapture: boolean) { |
| 255 | // https://github.com/angular/zone.js/issues/911, in IE, sometimes |
| 256 | // event will be undefined, so we need to use window.event |
| 257 | event = event || _global.event; |
| 258 | if (!event) { |
| 259 | return; |
| 260 | } |
| 261 | // event.target is needed for Samsung TV and SourceBuffer |
| 262 | // || global is needed https://github.com/angular/zone.js/issues/190 |
| 263 | const target: any = context || event.target || _global; |
| 264 | const tasks = target[zoneSymbolEventNames[event.type][isCapture ? TRUE_STR : FALSE_STR]]; |
| 265 | if (tasks) { |
| 266 | const errors = []; |
| 267 | // invoke all tasks which attached to current target with given event.type and capture = false |
| 268 | // for performance concern, if task.length === 1, just invoke |
| 269 | if (tasks.length === 1) { |
| 270 | const err = invokeTask(tasks[0], target, event); |
| 271 | err && errors.push(err); |
| 272 | } else { |
| 273 | // https://github.com/angular/zone.js/issues/836 |
| 274 | // copy the tasks array before invoke, to avoid |
| 275 | // the callback will remove itself or other listener |
| 276 | const copyTasks = tasks.slice(); |
| 277 | for (let i = 0; i < copyTasks.length; i++) { |
| 278 | if (event && (event as any)[IMMEDIATE_PROPAGATION_SYMBOL] === true) { |
| 279 | break; |
| 280 | } |
| 281 | const err = invokeTask(copyTasks[i], target, event); |
| 282 | err && errors.push(err); |
| 283 | } |
| 284 | } |
| 285 | // Since there is only one error, we don't need to schedule microTask |
| 286 | // to throw the error. |
| 287 | if (errors.length === 1) { |
| 288 | throw errors[0]; |
| 289 | } else { |
| 290 | for (let i = 0; i < errors.length; i++) { |
| 291 | const err = errors[i]; |
| 292 | api.nativeScheduleMicroTask(() => { |
| 293 | throw err; |
| 294 | }); |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | // global shared zoneAwareCallback to handle all event callback with capture = false |
| 301 | const globalZoneAwareCallback = function (this: unknown, event: Event) { |
no test coverage detected