fix(zone.js): browser-legacy should not reference Zone (#32016)
PR Close #32016
This commit is contained in:
		
							parent
							
								
									48487cb70e
								
							
						
					
					
						commit
						a91a55a6d2
					
				| @ -10,7 +10,6 @@ import {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNam | |||||||
| import {ADD_EVENT_LISTENER_STR, ArraySlice, FALSE_STR, ObjectCreate, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, attachOriginToPatched, bindArguments, isBrowser, isIEOrEdge, isMix, isNode, patchClass, patchMacroTask, patchMethod, patchOnProperties, wrapWithCurrentZone} from '../common/utils'; | import {ADD_EVENT_LISTENER_STR, ArraySlice, FALSE_STR, ObjectCreate, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, attachOriginToPatched, bindArguments, isBrowser, isIEOrEdge, isMix, isNode, patchClass, patchMacroTask, patchMethod, patchOnProperties, wrapWithCurrentZone} from '../common/utils'; | ||||||
| 
 | 
 | ||||||
| import {patchCallbacks} from './browser-util'; | import {patchCallbacks} from './browser-util'; | ||||||
| import {_redefineProperty} from './define-property'; |  | ||||||
| import {eventNames, filterProperties} from './property-descriptor'; | import {eventNames, filterProperties} from './property-descriptor'; | ||||||
| 
 | 
 | ||||||
| Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { | Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { | ||||||
| @ -44,7 +43,7 @@ Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { | |||||||
|   api.wrapWithCurrentZone = wrapWithCurrentZone; |   api.wrapWithCurrentZone = wrapWithCurrentZone; | ||||||
|   api.filterProperties = filterProperties; |   api.filterProperties = filterProperties; | ||||||
|   api.attachOriginToPatched = attachOriginToPatched; |   api.attachOriginToPatched = attachOriginToPatched; | ||||||
|   api._redefineProperty = _redefineProperty; |   api._redefineProperty = Object.defineProperty; | ||||||
|   api.patchCallbacks = patchCallbacks; |   api.patchCallbacks = patchCallbacks; | ||||||
|   api.getGlobalObjects = () => |   api.getGlobalObjects = () => | ||||||
|       ({globalSources, zoneSymbolEventNames, eventNames, isBrowser, isMix, isNode, TRUE_STR, |       ({globalSources, zoneSymbolEventNames, eventNames, isBrowser, isMix, isNode, TRUE_STR, | ||||||
|  | |||||||
| @ -10,15 +10,20 @@ | |||||||
|  * @suppress {missingRequire} |  * @suppress {missingRequire} | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import {propertyPatch} from './define-property'; | import {_redefineProperty, propertyPatch} from './define-property'; | ||||||
| import {eventTargetLegacyPatch} from './event-target-legacy'; | import {eventTargetLegacyPatch} from './event-target-legacy'; | ||||||
| import {propertyDescriptorLegacyPatch} from './property-descriptor-legacy'; | import {propertyDescriptorLegacyPatch} from './property-descriptor-legacy'; | ||||||
| import {registerElementPatch} from './register-element'; | import {registerElementPatch} from './register-element'; | ||||||
| 
 | 
 | ||||||
| (function(_global: any) { | (function(_global: any) { | ||||||
|   _global[Zone.__symbol__('legacyPatch')] = function() { |   const symbolPrefix = _global['__Zone_symbol_prefix'] || '__zone_symbol__'; | ||||||
|  |   function __symbol__(name: string) { return symbolPrefix + name; } | ||||||
|  |   _global[__symbol__('legacyPatch')] = function() { | ||||||
|     const Zone = _global['Zone']; |     const Zone = _global['Zone']; | ||||||
|     Zone.__load_patch('defineProperty', () => { propertyPatch(); }); |     Zone.__load_patch('defineProperty', (global: any, Zone: ZoneType, api: _ZonePrivate) => { | ||||||
|  |       api._redefineProperty = _redefineProperty; | ||||||
|  |       propertyPatch(); | ||||||
|  |     }); | ||||||
|     Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePrivate) => { |     Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePrivate) => { | ||||||
|       registerElementPatch(global, api); |       registerElementPatch(global, api); | ||||||
|     }); |     }); | ||||||
|  | |||||||
| @ -11,14 +11,19 @@ | |||||||
|  * things like redefining `createdCallback` on an element. |  * things like redefining `createdCallback` on an element. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| const zoneSymbol = Zone.__symbol__; | let zoneSymbol: any; | ||||||
| const _defineProperty = (Object as any)[zoneSymbol('defineProperty')] = Object.defineProperty; | let _defineProperty: any; | ||||||
| const _getOwnPropertyDescriptor = (Object as any)[zoneSymbol('getOwnPropertyDescriptor')] = | let _getOwnPropertyDescriptor: any; | ||||||
|     Object.getOwnPropertyDescriptor; | let _create: any; | ||||||
| const _create = Object.create; | let unconfigurablesKey: any; | ||||||
| const unconfigurablesKey = zoneSymbol('unconfigurables'); |  | ||||||
| 
 | 
 | ||||||
| export function propertyPatch() { | export function propertyPatch() { | ||||||
|  |   zoneSymbol = Zone.__symbol__; | ||||||
|  |   _defineProperty = (Object as any)[zoneSymbol('defineProperty')] = Object.defineProperty; | ||||||
|  |   _getOwnPropertyDescriptor = (Object as any)[zoneSymbol('getOwnPropertyDescriptor')] = | ||||||
|  |       Object.getOwnPropertyDescriptor; | ||||||
|  |   _create = Object.create; | ||||||
|  |   unconfigurablesKey = zoneSymbol('unconfigurables'); | ||||||
|   Object.defineProperty = function(obj: any, prop: string, desc: any) { |   Object.defineProperty = function(obj: any, prop: string, desc: any) { | ||||||
|     if (isUnconfigurable(obj, prop)) { |     if (isUnconfigurable(obj, prop)) { | ||||||
|       throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); |       throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); | ||||||
|  | |||||||
| @ -235,6 +235,11 @@ karma_tests = { | |||||||
|         "//packages/zone.js/dist:zone-evergreen-dist-dev-test", |         "//packages/zone.js/dist:zone-evergreen-dist-dev-test", | ||||||
|         "//packages/zone.js/dist:zone-testing-dist-dev-test", |         "//packages/zone.js/dist:zone-testing-dist-dev-test", | ||||||
|     ], |     ], | ||||||
|  |     "browser_legacy_test": [ | ||||||
|  |         "//packages/zone.js/dist:zone-legacy-dist-dev-test", | ||||||
|  |         "//packages/zone.js/dist:zone-evergreen-dist-dev-test", | ||||||
|  |         "//packages/zone.js/dist:zone-testing-dist-dev-test", | ||||||
|  |     ], | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| karma_test( | karma_test( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user