Skip to content

Commit

Permalink
Revise conditions under which dojo/when creates a promise; fixes #166…
Browse files Browse the repository at this point in the history
…67 in trunk !strict

git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@30605 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
kfranqueiro committed Feb 17, 2013
1 parent 133f6e2 commit 2ba455c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/when.js
Expand Up @@ -14,6 +14,12 @@ define([
t.t(this.deferred.promise === promise2);
},

"when() doesn't convert to promise if errback is passed but no callback": function(t){
var obj = {};
var result = when(obj, null, function(){});
t.t(result === obj);
},

"when() with a result value": function(t){
var obj = {};
var received;
Expand Down
4 changes: 2 additions & 2 deletions when.js
Expand Up @@ -36,8 +36,8 @@ define([
var nativePromise = receivedPromise && valueOrPromise instanceof Promise;

if(!receivedPromise){
if(callback){
return callback(valueOrPromise);
if(arguments.length > 1){
return callback ? callback(valueOrPromise) : valueOrPromise;
}else{
return new Deferred().resolve(valueOrPromise);
}
Expand Down

0 comments on commit 2ba455c

Please sign in to comment.