From 8c0029639337837f9dcf0ca20976af973828c055 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Mon, 9 Feb 2015 21:35:34 +0000 Subject: [PATCH 1/3] 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(); From 165303174761b34153ceffbeb1236d01164d1953 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Wed, 18 Feb 2015 22:24:46 -0500 Subject: [PATCH 2/3] fix m.request options signature --- docs/change-log.md | 1 + docs/mithril.request.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index 8fb182f8..273cd0b1 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -13,6 +13,7 @@ - fix routing bug in IE9 [#320](https://github.com/lhorie/mithril.js/issues/320) - fix ordering bug in m.trust when using HTML entities [#453](https://github.com/lhorie/mithril.js/issues/453) +- set promise's default value to initialValue if coming from m.request [#454](https://github.com/lhorie/mithril.js/issues/454) --- diff --git a/docs/mithril.request.md b/docs/mithril.request.md index ad89a482..2b474861 100644 --- a/docs/mithril.request.md +++ b/docs/mithril.request.md @@ -433,8 +433,8 @@ where: [Object data,] [Boolean background,] [any initialValue,] - [any unwrapSuccess(any data),] - [any unwrapError(any data),] + [any unwrapSuccess(any data, XMLHttpRequest xhr),] + [any unwrapError(any data, XMLHttpRequest xhr),] [String serialize(any dataToSerialize),] [any deserialize(String dataToDeserialize),] [any extract(XMLHttpRequest xhr, XHROptions options),] From d7373a050c7c040fc58e8016c6f411433eaeaf68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rory=20O=E2=80=99Kane?= Date: Mon, 23 Feb 2015 00:39:05 -0500 Subject: [PATCH 3/3] tools.md: explicitly say IE8 needs polyfills MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before adding this sentene, the first paragraph required me to look up `Array::indexOf` and those other functions to see what versions of Internet Explorer they were first supported in. Now, the relevance of that list is clear. I also fixed the capitalization of “ECMAScript”. --- docs/tools.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tools.md b/docs/tools.md index 99833267..a0c0ae76 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -57,7 +57,7 @@ You can use it by adding a reference to your Typescript files. This will allow t ### Internet Explorer Compatibility -Mithril relies on some Ecmascript 5 features, namely: `Array::indexOf`, `Array::map` and `Object::keys`, as well as the `JSON` object. +Mithril relies on some ECMAScript 5 features, namely: `Array::indexOf`, `Array::map` and `Object::keys`, as well as the `JSON` object. Internet Explorer 8 lacks native support for some of these features. The easiest way to polyfill these features is to include this script: @@ -79,4 +79,4 @@ You can also use other polyfills to support these features in IE7. Mithril also has a dependency on XMLHttpRequest. If you wish to support IE6, you'll need [a shim for it](https://gist.github.com/Contra/2709462). IE7 and lower do not support cross-domain AJAX requests. -In addition, note that most `m.route` modes rely on `history.pushState` in order to allow moving from one page to another without a browser refresh. [IE9 and lower](http://caniuse.com/#search=pushstate) do not support this feature and will gracefully degrade to page refreshes instead. \ No newline at end of file +In addition, note that most `m.route` modes rely on `history.pushState` in order to allow moving from one page to another without a browser refresh. [IE9 and lower](http://caniuse.com/#search=pushstate) do not support this feature and will gracefully degrade to page refreshes instead.