From a52c00fb5f3a18dcc202cab4555ca25fd0e483f5 Mon Sep 17 00:00:00 2001 From: Derrick Gilland Date: Mon, 27 Jul 2015 10:38:21 -0400 Subject: [PATCH 1/3] Reformat function syntax style to be in-line with overall style. --- mithril.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mithril.js b/mithril.js index 080c6052..dba767eb 100644 --- a/mithril.js +++ b/mithril.js @@ -1055,8 +1055,8 @@ 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(value) {return m.deferred().resolve(callback(value)).promise;}; return prop.then(function(value) { return propify(_callback(value).then(function() {return value;}), initialValue); }, function(reason) { From 1dc8c3163270790d32acb0426ee1f24c890e66ac Mon Sep 17 00:00:00 2001 From: Derrick Gilland Date: Mon, 27 Jul 2015 11:21:17 -0400 Subject: [PATCH 2/3] Don't pass value/reason to promise.finally callback. This behavior is inline with ES6. --- mithril.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mithril.js b/mithril.js index dba767eb..e858251e 100644 --- a/mithril.js +++ b/mithril.js @@ -1056,11 +1056,11 @@ var m = (function app(window, undefined) { }; prop["catch"] = prop.then.bind(null, null); prop["finally"] = function(callback) { - var _callback = function(value) {return m.deferred().resolve(callback(value)).promise;}; + 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; From 937b20984dcd7cb67814660819c8f78e264966d7 Mon Sep 17 00:00:00 2001 From: Derrick Gilland Date: Mon, 27 Jul 2015 11:29:08 -0400 Subject: [PATCH 3/3] Update promise.finally test for non-propagation of promise value to finally callback. --- tests/mithril-tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index 36c50785..294d2744 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -3916,11 +3916,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.