@@ -96,13 +96,10 @@ function patchEventTargetMethods(obj) {
96
96
// This is required for the addEventListener hook on the root zone.
97
97
obj [ keys . common . addEventListener ] = obj . addEventListener ;
98
98
obj . addEventListener = function ( eventName , handler , useCapturing ) {
99
- if ( ! handler ) {
100
- return ;
101
- }
102
- var eventType = eventName + ( useCapturing ? '$capturing' : '$bubbling' ) ;
103
- var fn ;
104
99
//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 ;
106
103
if ( handler . handleEvent ) {
107
104
// Have to pass in 'handler' reference as an argument here, otherwise it gets clobbered in
108
105
// IE9 by the arguments[1] assignment at end of this function.
@@ -125,30 +122,25 @@ function patchEventTargetMethods(obj) {
125
122
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined
126
123
// see https://github.com/angular/zone.js/issues/190
127
124
var target = this || global ;
128
-
129
125
return global . zone . addEventListener . apply ( target , arguments ) ;
130
126
} ;
131
127
132
128
// This is required for the removeEventListener hook on the root zone.
133
129
obj [ keys . common . removeEventListener ] = obj . removeEventListener ;
134
130
obj . removeEventListener = function ( eventName , handler , useCapturing ) {
135
- if ( ! handler ) {
136
- return ;
137
- }
138
131
var eventType = eventName + ( useCapturing ? '$capturing' : '$bubbling' ) ;
139
- if ( handler [ boundFnsKey ] && handler [ boundFnsKey ] [ eventType ] ) {
132
+ if ( handler && handler [ boundFnsKey ] && handler [ boundFnsKey ] [ eventType ] ) {
140
133
var _bound = handler [ boundFnsKey ] ;
141
134
arguments [ 1 ] = _bound [ eventType ] ;
142
135
delete _bound [ eventType ] ;
136
+ global . zone . dequeueTask ( handler [ originalFnKey ] ) ;
143
137
}
144
138
145
139
// - Inside a Web Worker, `this` is undefined, the context is `global`
146
140
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined
147
141
// see https://github.com/angular/zone.js/issues/190
148
142
var target = this || global ;
149
-
150
143
var result = global . zone . removeEventListener . apply ( target , arguments ) ;
151
- global . zone . dequeueTask ( handler [ originalFnKey ] ) ;
152
144
return result ;
153
145
} ;
154
146
} ;
0 commit comments