Browse Source

Handle null values in clearTimeout

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
7a48fd8455
  1. 8
      lib/timers.js
  2. 4
      test/pummel/test-timers.js

8
lib/timers.js

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

4
test/pummel/test-timers.js

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

Loading…
Cancel
Save