(_global: any, api: _ZonePrivate)
| 7 | */ |
| 8 | |
| 9 | export function eventTargetPatch(_global: any, api: _ZonePrivate) { |
| 10 | if ((Zone as any)[api.symbol('patchEventTarget')]) { |
| 11 | // EventTarget is already patched. |
| 12 | return; |
| 13 | } |
| 14 | const {eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX} = |
| 15 | api.getGlobalObjects()!; |
| 16 | // predefine all __zone_symbol__ + eventName + true/false string |
| 17 | for (let i = 0; i < eventNames.length; i++) { |
| 18 | const eventName = eventNames[i]; |
| 19 | const falseEventName = eventName + FALSE_STR; |
| 20 | const trueEventName = eventName + TRUE_STR; |
| 21 | const symbol = ZONE_SYMBOL_PREFIX + falseEventName; |
| 22 | const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; |
| 23 | zoneSymbolEventNames[eventName] = {}; |
| 24 | zoneSymbolEventNames[eventName][FALSE_STR] = symbol; |
| 25 | zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; |
| 26 | } |
| 27 | |
| 28 | const EVENT_TARGET = _global['EventTarget']; |
| 29 | if (!EVENT_TARGET || !EVENT_TARGET.prototype) { |
| 30 | return; |
| 31 | } |
| 32 | api.patchEventTarget(_global, api, [EVENT_TARGET && EVENT_TARGET.prototype]); |
| 33 | |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | export function patchEvent(global: any, api: _ZonePrivate) { |
| 38 | api.patchEventPrototype(global, api); |
no test coverage detected
searching dependent graphs…