fix m.sync resolution when empty array

This commit is contained in:
Leo Horie 2014-08-10 21:37:35 -04:00
parent 3fc0165c98
commit b86c4cec3f
2 changed files with 11 additions and 2 deletions

View file

@ -586,9 +586,13 @@ Mithril = m = new function app(window, undefined) {
var deferred = m.deferred()
var outstanding = args.length
var results = new Array(outstanding)
for (var i = 0; i < args.length; i++) {
args[i].then(synchronizer(i, true), synchronizer(i, false))
if (args.length > 0) {
for (var i = 0; i < args.length; i++) {
args[i].then(synchronizer(i, true), synchronizer(i, false))
}
}
else deferred.resolve()
return deferred.promise
}
function identity(value) {return value}

View file

@ -1517,6 +1517,11 @@ function testMithril(mock) {
deferred1.resolve("test")
return value[0] === "test" && value[1] === "foo"
})
test(function() {
var value = 1
m.sync([]).then(function() {value = 2})
return value == 2
})
//m.startComputation/m.endComputation
test(function() {