@@ -110,15 +110,18 @@ function patchEventTargetMethods(obj) {
110110 } ) ( handler ) ;
111111 } else {
112112 fn = handler ;
113- }
113+ }
114114
115115 handler [ originalFnKey ] = fn ;
116116 handler [ boundFnsKey ] = handler [ boundFnsKey ] || { } ;
117117 handler [ boundFnsKey ] [ eventType ] = handler [ boundFnsKey ] [ eventType ] || zone . bind ( fn ) ;
118118 arguments [ 1 ] = handler [ boundFnsKey ] [ eventType ] ;
119119 }
120120
121- var target = isWebWorker ( ) && ! this ? self : this ;
121+ // - Inside a Web Worker, `this` is undefined, the context is `global` (= `self`)
122+ // - When `addEventListener` is called on the global context in strict mode, `this` is undefined
123+ // see https://github.com/angular/zone.js/issues/190
124+ var target = this || global ;
122125
123126 return global . zone . addEventListener . apply ( target , arguments ) ;
124127 } ;
@@ -129,11 +132,15 @@ function patchEventTargetMethods(obj) {
129132 var eventType = eventName + ( useCapturing ? '$capturing' : '$bubbling' ) ;
130133 if ( handler [ boundFnsKey ] && handler [ boundFnsKey ] [ eventType ] ) {
131134 var _bound = handler [ boundFnsKey ] ;
132-
133135 arguments [ 1 ] = _bound [ eventType ] ;
134136 delete _bound [ eventType ] ;
135137 }
136- var target = isWebWorker ( ) && ! this ? self : this ;
138+
139+ // - Inside a Web Worker, `this` is undefined, the context is `global`
140+ // - When `addEventListener` is called on the global context in strict mode, `this` is undefined
141+ // see https://github.com/angular/zone.js/issues/190
142+ var target = this || global ;
143+
137144 var result = global . zone . removeEventListener . apply ( target , arguments ) ;
138145 global . zone . dequeueTask ( handler [ originalFnKey ] ) ;
139146 return result ;
0 commit comments