@@ -96,13 +96,10 @@ function patchEventTargetMethods(obj) {
9696 // This is required for the addEventListener hook on the root zone.
9797 obj [ keys . common . addEventListener ] = obj . addEventListener ;
9898 obj . addEventListener = function ( eventName , handler , useCapturing ) {
99- if ( ! handler ) {
100- return ;
101- }
102- var eventType = eventName + ( useCapturing ? '$capturing' : '$bubbling' ) ;
103- var fn ;
10499 //Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150
105- if ( handler . toString ( ) !== "[object FunctionWrapper]" ) {
100+ if ( handler && handler . toString ( ) !== "[object FunctionWrapper]" ) {
101+ var eventType = eventName + ( useCapturing ? '$capturing' : '$bubbling' ) ;
102+ var fn ;
106103 if ( handler . handleEvent ) {
107104 // Have to pass in 'handler' reference as an argument here, otherwise it gets clobbered in
108105 // IE9 by the arguments[1] assignment at end of this function.
@@ -125,30 +122,25 @@ function patchEventTargetMethods(obj) {
125122 // - When `addEventListener` is called on the global context in strict mode, `this` is undefined
126123 // see https://github.com/angular/zone.js/issues/190
127124 var target = this || global ;
128-
129125 return global . zone . addEventListener . apply ( target , arguments ) ;
130126 } ;
131127
132128 // This is required for the removeEventListener hook on the root zone.
133129 obj [ keys . common . removeEventListener ] = obj . removeEventListener ;
134130 obj . removeEventListener = function ( eventName , handler , useCapturing ) {
135- if ( ! handler ) {
136- return ;
137- }
138131 var eventType = eventName + ( useCapturing ? '$capturing' : '$bubbling' ) ;
139- if ( handler [ boundFnsKey ] && handler [ boundFnsKey ] [ eventType ] ) {
132+ if ( handler && handler [ boundFnsKey ] && handler [ boundFnsKey ] [ eventType ] ) {
140133 var _bound = handler [ boundFnsKey ] ;
141134 arguments [ 1 ] = _bound [ eventType ] ;
142135 delete _bound [ eventType ] ;
136+ global . zone . dequeueTask ( handler [ originalFnKey ] ) ;
143137 }
144138
145139 // - Inside a Web Worker, `this` is undefined, the context is `global`
146140 // - When `addEventListener` is called on the global context in strict mode, `this` is undefined
147141 // see https://github.com/angular/zone.js/issues/190
148142 var target = this || global ;
149-
150143 var result = global . zone . removeEventListener . apply ( target , arguments ) ;
151- global . zone . dequeueTask ( handler [ originalFnKey ] ) ;
152144 return result ;
153145 } ;
154146} ;
0 commit comments