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

Commit

Permalink
fix(patch): check timer patch return undefined (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and mhevery committed Feb 7, 2017
1 parent f300658 commit 47962df
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/common/timers.ts
Expand Up @@ -52,8 +52,11 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam
return task;
}
// Node.js must additionally support the ref and unref functions.
const handle = (<TimerOptions>task.data).handleId;
if ((<any>handle).ref && (<any>handle).unref) {
const handle: any = (<TimerOptions>task.data).handleId;
// check whether handle is null, because some polyfill or browser
// may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame
if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' &&
typeof handle.unref === 'function') {
(<any>task).ref = (<any>handle).ref.bind(handle);
(<any>task).unref = (<any>handle).unref.bind(handle);
}
Expand Down

0 comments on commit 47962df

Please sign in to comment.