From 9d232466b316d178b6818ad43b6c73f4583002b7 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 17 Mar 2016 11:22:09 -0700 Subject: [PATCH] fix(patching): call native cancel method Fixes #278 --- lib/browser/browser.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index be8c4f36c..38f9316ec 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -66,7 +66,7 @@ function patchTimer( return clearNative((task.data).handleId); } - var setNative = patchMethod(window, setName, () => function(self: any, args: any[]) { + var setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) { if (typeof args[0] === 'function') { var zone = Zone.current; var options:TimerOptions = { @@ -78,13 +78,17 @@ function patchTimer( return zone.scheduleMacroTask(setName, args[0], options, scheduleTask, clearTask); } else { // cause an error by calling it directly. - return setNative.apply(window, args); + return delegate.apply(window, args); } }); - var clearNative = patchMethod(window, cancelName, () => function(self: any, args: any[]) { + var clearNative = patchMethod(window, cancelName, (delegate: Function) => function(self: any, args: any[]) { var task: Task = args[0]; - task.zone.cancelTask(task); + if (typeof args[0] === 'function') { + task.zone.cancelTask(task); + } else { + delegate.apply(window, args); + } }); }