@@ -230,53 +230,86 @@ export const eventNames = globalEventHandlersEventNames.concat(
230230 webglEventNames , formEventNames , detailEventNames , documentEventNames , windowEventNames ,
231231 htmlElementEventNames , ieElementEventNames ) ;
232232
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+
233259export function propertyDescriptorPatch ( api : _ZonePrivate , _global : any ) {
234260 if ( isNode && ! isMix ) {
235261 return ;
236262 }
237263
238264 const supportsWebSocket = typeof WebSocket !== 'undefined' ;
239265 if ( canPatchViaPropertyDescriptor ( ) ) {
266+ const ignoreProperties : IgnoreProperty [ ] = _global . __Zone_ignore_on_properties ;
240267 // for browsers that we can patch the descriptor: Chrome & Firefox
241268 if ( isBrowser ) {
242269 // in IE/Edge, onProp not exist in window object, but in WindowPrototype
243270 // 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 ) ;
246275
247276 if ( typeof ( < any > window ) [ 'SVGElement' ] !== 'undefined' ) {
248- patchOnProperties ( ( < any > window ) [ 'SVGElement' ] . prototype , eventNames ) ;
277+ patchFilteredProperties (
278+ ( < any > window ) [ 'SVGElement' ] . prototype , eventNames , ignoreProperties ) ;
249279 }
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 ) ;
257290
258291 const HTMLMarqueeElement = ( window as any ) [ 'HTMLMarqueeElement' ] ;
259292 if ( HTMLMarqueeElement ) {
260- patchOnProperties ( HTMLMarqueeElement . prototype , marqueeEventNames ) ;
293+ patchFilteredProperties ( HTMLMarqueeElement . prototype , marqueeEventNames , ignoreProperties ) ;
261294 }
262295 }
263- patchOnProperties ( XMLHttpRequest . prototype , XMLHttpRequestEventNames ) ;
296+ patchFilteredProperties ( XMLHttpRequest . prototype , XMLHttpRequestEventNames , ignoreProperties ) ;
264297 const XMLHttpRequestEventTarget = _global [ 'XMLHttpRequestEventTarget' ] ;
265298 if ( XMLHttpRequestEventTarget ) {
266- patchOnProperties (
299+ patchFilteredProperties (
267300 XMLHttpRequestEventTarget && XMLHttpRequestEventTarget . prototype ,
268- XMLHttpRequestEventNames ) ;
301+ XMLHttpRequestEventNames , ignoreProperties ) ;
269302 }
270303 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 ) ;
277310 }
278311 if ( supportsWebSocket ) {
279- patchOnProperties ( WebSocket . prototype , websocketEventNames ) ;
312+ patchFilteredProperties ( WebSocket . prototype , websocketEventNames , ignoreProperties ) ;
280313 }
281314 } else {
282315 // Safari, Android browsers (Jelly Bean)
0 commit comments