Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: scothis/when
...
head fork: scothis/when
  • 5 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
4 README.md
@@ -23,6 +23,10 @@ when.js was derived from the async core of [wire.js](https://github.com/cujojs/w
What's New?
===========
+### 1.0.3
+
+* Fix for specific situation where `null` could incorrectly be used as a promise resolution value ([#23](https://github.com/cujojs/when/pull/23))
+
### 1.0.2
* Updated README for running unit tests in both Node and Browsers. See **Running the Unit Tests** below.
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "when",
- "version": "1.0.2",
+ "version": "1.0.3",
"description": "A lightweight Promise and when() implementation, plus other async goodies.",
"keywords": ["promises", "when", "async"],
"licenses": [
View
16 test/cancelable.js
@@ -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();
+ }
+ );
}
});
View
24 test/promise.js
@@ -66,6 +66,28 @@ buster.testCase('promise', {
},
+ 'should forward result when callback is null': function(done) {
+ var d = when.defer();
+
+ function fail(e) {
+ buster.fail(e);
+ done();
+ }
+
+ d.promise.then(
+ null,
+ fail
+ ).then(
+ function(val) {
+ assert.equals(val, 1);
+ done();
+ },
+ fail
+ );
+
+ d.resolve(1);
+ },
+
'should forward callback result to next callback': function(done) {
var d = when.defer();
@@ -268,7 +290,7 @@ buster.testCase('promise', {
);
d.reject(1);
- },
+ }
});
})(
View
4 when.js
@@ -9,7 +9,7 @@
* Licensed under the MIT License at:
* http://www.opensource.org/licenses/mit-license.php
*
- * @version 1.0.2
+ * @version 1.0.3
*/
(function(define) {
@@ -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);

No commit comments for this range

Something went wrong with that request. Please try again.