
committed by
Kara Erickson

parent
7b3bcc23af
commit
5eb7426216
39
packages/zone.js/lib/browser/event-target.ts
Normal file
39
packages/zone.js/lib/browser/event-target.ts
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
export function eventTargetPatch(_global: any, api: _ZonePrivate) {
|
||||
if ((Zone as any)[api.symbol('patchEventTarget')]) {
|
||||
// EventTarget is already patched.
|
||||
return;
|
||||
}
|
||||
const {eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX} =
|
||||
api.getGlobalObjects() !;
|
||||
// predefine all __zone_symbol__ + eventName + true/false string
|
||||
for (let i = 0; i < eventNames.length; i++) {
|
||||
const eventName = eventNames[i];
|
||||
const falseEventName = eventName + FALSE_STR;
|
||||
const trueEventName = eventName + TRUE_STR;
|
||||
const symbol = ZONE_SYMBOL_PREFIX + falseEventName;
|
||||
const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
|
||||
zoneSymbolEventNames[eventName] = {};
|
||||
zoneSymbolEventNames[eventName][FALSE_STR] = symbol;
|
||||
zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture;
|
||||
}
|
||||
|
||||
const EVENT_TARGET = _global['EventTarget'];
|
||||
if (!EVENT_TARGET || !EVENT_TARGET.prototype) {
|
||||
return;
|
||||
}
|
||||
api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function patchEvent(global: any, api: _ZonePrivate) {
|
||||
api.patchEventPrototype(global, api);
|
||||
}
|
Reference in New Issue
Block a user