From ad5c0c8df779496ce21294cfef590c30bfba0a4a Mon Sep 17 00:00:00 2001 From: Matthew Hill Date: Wed, 23 Sep 2015 13:01:25 +0100 Subject: [PATCH] fix(utils): fixes event target patch in web workers --- lib/utils.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index c322a0bd6..41754c071 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -118,7 +118,9 @@ function patchEventTargetMethods(obj) { arguments[1] = handler[boundFnsKey][eventType]; } - return global.zone.addEventListener.apply(this, arguments); + var target = isWebWorker() && !this ? self : this; + + return global.zone.addEventListener.apply(target, arguments); }; // This is required for the removeEventListener hook on the root zone. @@ -131,7 +133,8 @@ function patchEventTargetMethods(obj) { arguments[1] = _bound[eventType]; delete _bound[eventType]; } - var result = global.zone.removeEventListener.apply(this, arguments); + var target = isWebWorker() && !this ? self : this; + var result = global.zone.removeEventListener.apply(target, arguments); global.zone.dequeueTask(handler[originalFnKey]); return result; };