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 {patchCallbacks} from './browser-util';
|
||||
import {_redefineProperty} from './define-property';
|
||||
import {eventNames, filterProperties} from './property-descriptor';
|
||||
|
||||
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.filterProperties = filterProperties;
|
||||
api.attachOriginToPatched = attachOriginToPatched;
|
||||
api._redefineProperty = _redefineProperty;
|
||||
api._redefineProperty = Object.defineProperty;
|
||||
api.patchCallbacks = patchCallbacks;
|
||||
api.getGlobalObjects = () =>
|
||||
({globalSources, zoneSymbolEventNames, eventNames, isBrowser, isMix, isNode, TRUE_STR,
|
||||
|
|
|
@ -10,15 +10,20 @@
|
|||
* @suppress {missingRequire}
|
||||
*/
|
||||
|
||||
import {propertyPatch} from './define-property';
|
||||
import {_redefineProperty, propertyPatch} from './define-property';
|
||||
import {eventTargetLegacyPatch} from './event-target-legacy';
|
||||
import {propertyDescriptorLegacyPatch} from './property-descriptor-legacy';
|
||||
import {registerElementPatch} from './register-element';
|
||||
|
||||
(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'];
|
||||
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) => {
|
||||
registerElementPatch(global, api);
|
||||
});
|
||||
|
|
|
@ -11,14 +11,19 @@
|
|||
* things like redefining `createdCallback` on an element.
|
||||
*/
|
||||
|
||||
const zoneSymbol = Zone.__symbol__;
|
||||
const _defineProperty = (Object as any)[zoneSymbol('defineProperty')] = Object.defineProperty;
|
||||
const _getOwnPropertyDescriptor = (Object as any)[zoneSymbol('getOwnPropertyDescriptor')] =
|
||||
Object.getOwnPropertyDescriptor;
|
||||
const _create = Object.create;
|
||||
const unconfigurablesKey = zoneSymbol('unconfigurables');
|
||||
let zoneSymbol: any;
|
||||
let _defineProperty: any;
|
||||
let _getOwnPropertyDescriptor: any;
|
||||
let _create: any;
|
||||
let unconfigurablesKey: any;
|
||||
|
||||
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) {
|
||||
if (isUnconfigurable(obj, prop)) {
|
||||
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-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(
|
||||
|
|
Loading…
Reference in New Issue