Handle null values in clearTimeout

This commit is contained in:
Ryan Dahl 2010-10-29 00:00:43 -07:00
parent fa7dcbec8b
commit 7a48fd8455
2 changed files with 9 additions and 3 deletions

View File

@ -209,9 +209,11 @@ exports.setTimeout = function (callback, after) {
exports.clearTimeout = function (timer) {
timer.callback = timer._onTimeout = null;
exports.unenroll(timer);
if (timer instanceof Timer) timer.stop(); // for after === 0
if (timer) {
timer.callback = timer._onTimeout = null;
exports.unenroll(timer);
if (timer instanceof Timer) timer.stop(); // for after === 0
}
};

View File

@ -8,6 +8,10 @@ var WINDOW = 200; // why is does this need to be so big?
var interval_count = 0;
var setTimeout_called = false;
// check that these don't blow up.
clearTimeout(null);
clearInterval(null);
assert.equal(true, setTimeout instanceof Function);
var starttime = new Date;
setTimeout(function () {