Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 3a4bfbd

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(task): fix #832, fix #835, task.data should be an object (#834)
* fix(task): fix #832, task.data should be an object * fix #835, add reference to _global * refactor to use _global from _load_patch
1 parent 79baffb commit 3a4bfbd

File tree

9 files changed

+389
-359
lines changed

9 files changed

+389
-359
lines changed

lib/browser/browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate
5252
});
5353

5454
Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
55-
propertyDescriptorPatch(global);
55+
propertyDescriptorPatch(api, global);
5656
propertyPatch();
5757
registerElementPatch(global);
5858
});

lib/browser/event-target.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {FALSE_STR, globalSources, patchEventTargetMethods, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbolEventNames} from '../common/events';
9+
import {FALSE_STR, globalSources, patchEventTarget, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbolEventNames} from '../common/events';
1010
import {attachOriginToPatched, isIEOrEdge, zoneSymbol} from '../common/utils';
1111

1212
import {eventNames} from './property-descriptor';
@@ -96,11 +96,12 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) {
9696
return true;
9797
};
9898

99+
const apiTypes: any[] = [];
99100
for (let i = 0; i < apis.length; i++) {
100101
const type = _global[apis[i]];
101-
patchEventTargetMethods(type && type.prototype, {validateHandler: checkIEAndCrossContext});
102+
apiTypes.push(type && type.prototype);
102103
}
104+
patchEventTarget(api, _global, apiTypes, {validateHandler: checkIEAndCrossContext});
103105

104-
api.patchEventTargetMethods = patchEventTargetMethods;
105106
return true;
106107
}

lib/browser/property-descriptor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export const eventNames = globalEventHandlersEventNames.concat(
226226
webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames,
227227
htmlElementEventNames, ieElementEventNames);
228228

229-
export function propertyDescriptorPatch(_global: any) {
229+
export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) {
230230
if (isNode && !isMix) {
231231
return;
232232
}
@@ -279,7 +279,7 @@ export function propertyDescriptorPatch(_global: any) {
279279
patchViaCapturingAllTheEvents();
280280
patchClass('XMLHttpRequest');
281281
if (supportsWebSocket) {
282-
webSocketPatch.apply(_global);
282+
webSocketPatch.apply(api, _global);
283283
}
284284
}
285285
}

lib/browser/websocket.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {patchEventTargetMethods} from '../common/events';
9+
import {patchEventTarget} from '../common/events';
1010
import {patchOnProperties} from '../common/utils';
1111

1212
// we have to patch the instance since the proto is non-configurable
13-
export function apply(_global: any) {
13+
export function apply(api: _ZonePrivate, _global: any) {
1414
const WS = (<any>_global).WebSocket;
1515
// On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener
1616
// On older Chrome, no need since EventTarget was already patched
1717
if (!(<any>_global).EventTarget) {
18-
patchEventTargetMethods(WS.prototype);
18+
patchEventTarget(api, _global, [WS.prototype]);
1919
}
2020
(<any>_global).WebSocket = function(a: any, b: any) {
2121
const socket = arguments.length > 1 ? new WS(a, b) : new WS(a);

0 commit comments

Comments
 (0)