diff --git a/packages/core/src/tools/getZoneJsOriginalValue.spec.ts b/packages/core/src/tools/getZoneJsOriginalValue.spec.ts index 960720c364..88850387bc 100644 --- a/packages/core/src/tools/getZoneJsOriginalValue.spec.ts +++ b/packages/core/src/tools/getZoneJsOriginalValue.spec.ts @@ -1,5 +1,6 @@ import { stubZoneJs } from '../../test/stubZoneJs' +import type { BrowserWindowWithZoneJs } from './getZoneJsOriginalValue' import { getZoneJsOriginalValue } from './getZoneJsOriginalValue' import { noop } from './utils' @@ -22,11 +23,17 @@ describe('getZoneJsOriginalValue', () => { expect(getZoneJsOriginalValue(object, 'name')).toBe(originalValue) }) - it("returns undefined if Zone is defined but didn't patch that method", () => { + it("returns the original value if Zone is defined but didn't patch that method", () => { zoneJsStub = stubZoneJs() expect(getZoneJsOriginalValue(object, 'name')).toBe(originalValue) }) + it('returns the original value if Zone is defined but does not define the __symbol__ function', () => { + zoneJsStub = stubZoneJs() + delete (window as BrowserWindowWithZoneJs).Zone!.__symbol__ + expect(getZoneJsOriginalValue(object, 'name')).toBe(originalValue) + }) + it('returns the original value if Zone did patch the method', () => { zoneJsStub = stubZoneJs() zoneJsStub.replaceProperty(object, 'name', noop) diff --git a/packages/core/src/tools/getZoneJsOriginalValue.ts b/packages/core/src/tools/getZoneJsOriginalValue.ts index 786da8e6fd..a4b628b879 100644 --- a/packages/core/src/tools/getZoneJsOriginalValue.ts +++ b/packages/core/src/tools/getZoneJsOriginalValue.ts @@ -1,6 +1,9 @@ export interface BrowserWindowWithZoneJs extends Window { Zone?: { - __symbol__: (name: string) => string + // All Zone.js versions expose the __symbol__ method, but we observed that some website have a + // 'Zone' global variable unrelated to Zone.js, so let's consider this method optional + // nonetheless. + __symbol__?: (name: string) => string } } @@ -23,7 +26,7 @@ export function getZoneJsOriginalValue