@@ -230,53 +230,86 @@ export const eventNames = globalEventHandlersEventNames.concat(
230
230
webglEventNames , formEventNames , detailEventNames , documentEventNames , windowEventNames ,
231
231
htmlElementEventNames , ieElementEventNames ) ;
232
232
233
+ export interface IgnoreProperty {
234
+ target : any ;
235
+ ignoreProperties : string [ ] ;
236
+ }
237
+
238
+ function filterProperties (
239
+ target : any , onProperties : string [ ] , ignoreProperties : IgnoreProperty [ ] ) : string [ ] {
240
+ if ( ! ignoreProperties ) {
241
+ return onProperties ;
242
+ }
243
+
244
+ const tip : IgnoreProperty [ ] = ignoreProperties . filter ( ip => ip . target === target ) ;
245
+ if ( ! tip || tip . length === 0 ) {
246
+ return onProperties ;
247
+ }
248
+
249
+ const targetIgnoreProperties : string [ ] = tip [ 0 ] . ignoreProperties ;
250
+ return onProperties . filter ( op => targetIgnoreProperties . indexOf ( op ) === - 1 ) ;
251
+ }
252
+
253
+ export function patchFilteredProperties (
254
+ target : any , onProperties : string [ ] , ignoreProperties : IgnoreProperty [ ] , prototype ?: any ) {
255
+ const filteredProperties : string [ ] = filterProperties ( target , onProperties , ignoreProperties ) ;
256
+ patchOnProperties ( target , filteredProperties , prototype ) ;
257
+ }
258
+
233
259
export function propertyDescriptorPatch ( api : _ZonePrivate , _global : any ) {
234
260
if ( isNode && ! isMix ) {
235
261
return ;
236
262
}
237
263
238
264
const supportsWebSocket = typeof WebSocket !== 'undefined' ;
239
265
if ( canPatchViaPropertyDescriptor ( ) ) {
266
+ const ignoreProperties : IgnoreProperty [ ] = _global . __Zone_ignore_on_properties ;
240
267
// for browsers that we can patch the descriptor: Chrome & Firefox
241
268
if ( isBrowser ) {
242
269
// in IE/Edge, onProp not exist in window object, but in WindowPrototype
243
270
// so we need to pass WindowPrototype to check onProp exist or not
244
- patchOnProperties ( window , eventNames . concat ( [ 'messageerror' ] ) , Object . getPrototypeOf ( window ) ) ;
245
- patchOnProperties ( Document . prototype , eventNames ) ;
271
+ patchFilteredProperties (
272
+ window , eventNames . concat ( [ 'messageerror' ] ) , ignoreProperties ,
273
+ Object . getPrototypeOf ( window ) ) ;
274
+ patchFilteredProperties ( Document . prototype , eventNames , ignoreProperties ) ;
246
275
247
276
if ( typeof ( < any > window ) [ 'SVGElement' ] !== 'undefined' ) {
248
- patchOnProperties ( ( < any > window ) [ 'SVGElement' ] . prototype , eventNames ) ;
277
+ patchFilteredProperties (
278
+ ( < any > window ) [ 'SVGElement' ] . prototype , eventNames , ignoreProperties ) ;
249
279
}
250
- patchOnProperties ( Element . prototype , eventNames ) ;
251
- patchOnProperties ( HTMLElement . prototype , eventNames ) ;
252
- patchOnProperties ( HTMLMediaElement . prototype , mediaElementEventNames ) ;
253
- patchOnProperties ( HTMLFrameSetElement . prototype , windowEventNames . concat ( frameSetEventNames ) ) ;
254
- patchOnProperties ( HTMLBodyElement . prototype , windowEventNames . concat ( frameSetEventNames ) ) ;
255
- patchOnProperties ( HTMLFrameElement . prototype , frameEventNames ) ;
256
- patchOnProperties ( HTMLIFrameElement . prototype , frameEventNames ) ;
280
+ patchFilteredProperties ( Element . prototype , eventNames , ignoreProperties ) ;
281
+ patchFilteredProperties ( HTMLElement . prototype , eventNames , ignoreProperties ) ;
282
+ patchFilteredProperties ( HTMLMediaElement . prototype , mediaElementEventNames , ignoreProperties ) ;
283
+ patchFilteredProperties (
284
+ HTMLFrameSetElement . prototype , windowEventNames . concat ( frameSetEventNames ) ,
285
+ ignoreProperties ) ;
286
+ patchFilteredProperties (
287
+ HTMLBodyElement . prototype , windowEventNames . concat ( frameSetEventNames ) , ignoreProperties ) ;
288
+ patchFilteredProperties ( HTMLFrameElement . prototype , frameEventNames , ignoreProperties ) ;
289
+ patchFilteredProperties ( HTMLIFrameElement . prototype , frameEventNames , ignoreProperties ) ;
257
290
258
291
const HTMLMarqueeElement = ( window as any ) [ 'HTMLMarqueeElement' ] ;
259
292
if ( HTMLMarqueeElement ) {
260
- patchOnProperties ( HTMLMarqueeElement . prototype , marqueeEventNames ) ;
293
+ patchFilteredProperties ( HTMLMarqueeElement . prototype , marqueeEventNames , ignoreProperties ) ;
261
294
}
262
295
}
263
- patchOnProperties ( XMLHttpRequest . prototype , XMLHttpRequestEventNames ) ;
296
+ patchFilteredProperties ( XMLHttpRequest . prototype , XMLHttpRequestEventNames , ignoreProperties ) ;
264
297
const XMLHttpRequestEventTarget = _global [ 'XMLHttpRequestEventTarget' ] ;
265
298
if ( XMLHttpRequestEventTarget ) {
266
- patchOnProperties (
299
+ patchFilteredProperties (
267
300
XMLHttpRequestEventTarget && XMLHttpRequestEventTarget . prototype ,
268
- XMLHttpRequestEventNames ) ;
301
+ XMLHttpRequestEventNames , ignoreProperties ) ;
269
302
}
270
303
if ( typeof IDBIndex !== 'undefined' ) {
271
- patchOnProperties ( IDBIndex . prototype , IDBIndexEventNames ) ;
272
- patchOnProperties ( IDBRequest . prototype , IDBIndexEventNames ) ;
273
- patchOnProperties ( IDBOpenDBRequest . prototype , IDBIndexEventNames ) ;
274
- patchOnProperties ( IDBDatabase . prototype , IDBIndexEventNames ) ;
275
- patchOnProperties ( IDBTransaction . prototype , IDBIndexEventNames ) ;
276
- patchOnProperties ( IDBCursor . prototype , IDBIndexEventNames ) ;
304
+ patchFilteredProperties ( IDBIndex . prototype , IDBIndexEventNames , ignoreProperties ) ;
305
+ patchFilteredProperties ( IDBRequest . prototype , IDBIndexEventNames , ignoreProperties ) ;
306
+ patchFilteredProperties ( IDBOpenDBRequest . prototype , IDBIndexEventNames , ignoreProperties ) ;
307
+ patchFilteredProperties ( IDBDatabase . prototype , IDBIndexEventNames , ignoreProperties ) ;
308
+ patchFilteredProperties ( IDBTransaction . prototype , IDBIndexEventNames , ignoreProperties ) ;
309
+ patchFilteredProperties ( IDBCursor . prototype , IDBIndexEventNames , ignoreProperties ) ;
277
310
}
278
311
if ( supportsWebSocket ) {
279
- patchOnProperties ( WebSocket . prototype , websocketEventNames ) ;
312
+ patchFilteredProperties ( WebSocket . prototype , websocketEventNames , ignoreProperties ) ;
280
313
}
281
314
} else {
282
315
// Safari, Android browsers (Jelly Bean)
0 commit comments