diff --git a/mithril.js b/mithril.js index 87eeb31f..3bcde247 100644 --- a/mithril.js +++ b/mithril.js @@ -1086,12 +1086,12 @@ var m = (function app(window, undefined) { return propify(promise.then(resolve, reject), initialValue); }; prop["catch"] = prop.then.bind(null, null); - prop["finally"] = function(callback){ - var _callback = function(value){return m.deferred().resolve(callback(value)).promise;}; + prop["finally"] = function(callback) { + var _callback = function() {return m.deferred().resolve(callback()).promise;}; return prop.then(function(value) { - return propify(_callback(value).then(function() {return value;}), initialValue); + return propify(_callback().then(function() {return value;}), initialValue); }, function(reason) { - return propify(_callback(reason).then(function() {throw new Error(reason);}), initialValue); + return propify(_callback().then(function() {throw new Error(reason);}), initialValue); }); }; return prop; diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index f1597309..8967c268 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -3923,11 +3923,11 @@ function testMithril(mock) { return prop().message === "error occurred" && error().message === "error occurred" }) test(function() { - // Data returned by then() functions propagate to finally(). + // Data returned by then() functions do *not* propagate to finally(). var data = m.prop(""); var prop = m.request({method: "GET", url: "test"}).then(function() {return "foo"})["finally"](data) mock.XMLHttpRequest.$instances.pop().onreadystatechange() - return prop() === "foo" && data() === "foo" + return prop() === "foo" && data() === "" }) test(function() { // Data returned by finally() functions do *not* propagate to next promise.