diff --git a/lib/browser/event-target-legacy.ts b/lib/browser/event-target-legacy.ts index 9a4b025ef..420ffb2af 100644 --- a/lib/browser/event-target-legacy.ts +++ b/lib/browser/event-target-legacy.ts @@ -24,7 +24,7 @@ export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { // Workaround for: https://github.com/google/tracing-framework/issues/555 apis = WTF_ISSUE_555_ARRAY.map((v) => 'HTML' + v + 'Element').concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - // EventTarget is already patched in browser.ts + apis.push(EVENT_TARGET); } else { // Note: EventTarget is not available in all browsers, // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget @@ -101,7 +101,7 @@ export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { // vh is validateHandler to check event handler // is valid or not(for security check) api.patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); - + (Zone as any)[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; return true; } diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index abbe51837..525f52976 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -7,6 +7,10 @@ */ 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