Skip to content

Commit

Permalink
Fix #23 - incorrect check for callback allowed passing null as a call…
Browse files Browse the repository at this point in the history
…back to clobber the resolution value.
  • Loading branch information
briancavalier committed Mar 9, 2012
1 parent e323bda commit 364eafe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions test/cancelable.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ buster.testCase('when/cancelable', {
done();
}
);
},

'should propagate the unaltered resolution value': function(done) {
var c = cancelable(when.defer(), function() { return false; });
c.resolve(true);

c.then(
function(val) {
assert(val);
done();
},
function() {
buster.fail();
done();
}
);

}
});
Expand Down
2 changes: 1 addition & 1 deletion when.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ define(function() {

var nextValue;
try {
nextValue = callback && callback(value);
if(callback) nextValue = callback(value);
return promise(nextValue === undef ? value : nextValue);
} catch(e) {
return rejected(e);
Expand Down

0 comments on commit 364eafe

Please sign in to comment.