Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix(patching): call native cancel method #279

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function patchTimer(
return clearNative((<TimerOptions>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 = {
Expand All @@ -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);
}
});
}