From 8c0029639337837f9dcf0ca20976af973828c055 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Mon, 9 Feb 2015 21:35:34 +0000 Subject: [PATCH] propify: Fix chaining to return original m.prop --- mithril.js | 3 ++- tests/mithril-tests.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index e02b3049..0ae27a31 100644 --- a/mithril.js +++ b/mithril.js @@ -723,7 +723,8 @@ var m = (function app(window, undefined) { var prop = m.prop(); promise.then(prop); prop.then = function(resolve, reject) { - return propify(promise.then(resolve, reject)) + promise = promise.then(resolve, reject).then(prop); + return prop; }; return prop } diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index a6c161ed..29416db3 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -1836,6 +1836,13 @@ function testMithril(mock) { xhr.onreadystatechange() return xhr.$headers["Content-Type"] === undefined }) + test(function() { + var prop = m.request({method: "POST", url: "test", initialValue: "foo"}).then(function(data) { return data; }) + var initialValue = prop(); + mock.XMLHttpRequest.$instances.pop().onreadystatechange() + + return initialValue === "foo" + }) test(function() { var prop = m.request({method: "POST", url: "test", initialValue: "foo"}) var initialValue = prop();