From fa719a4a60773c5935fd28b856918936791ed484 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Sat, 7 Feb 2015 14:37:38 +0000 Subject: [PATCH 1/5] request: Send xhrRequest to unwrap method --- mithril.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index 07cd891e..e02b3049 100644 --- a/mithril.js +++ b/mithril.js @@ -989,7 +989,7 @@ var m = (function app(window, undefined) { try { e = e || event; var unwrap = (e.type === "load" ? xhrOptions.unwrapSuccess : xhrOptions.unwrapError) || identity; - var response = unwrap(deserialize(extract(e.target, xhrOptions))); + var response = unwrap(deserialize(extract(e.target, xhrOptions)), e.target); if (e.type === "load") { if (type.call(response) === ARRAY && xhrOptions.type) { for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i]) From 2fa463218604137493148b8858e1978f3645970a Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Mon, 9 Feb 2015 23:11:20 -0500 Subject: [PATCH 2/5] fix docs about shouldReplaceHistory --- docs/layout/api.html | 2 +- docs/mithril.route.md | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/layout/api.html b/docs/layout/api.html index 5d05c2c4..5507f979 100644 --- a/docs/layout/api.html +++ b/docs/layout/api.html @@ -35,7 +35,7 @@
  • m.route
    • m.route(rootElement, defaultRoute, routes)
    • -
    • m.route(path, params)
    • +
    • m.route(path, params, replaceHistory)
    • m.route()
    • m.route(element)
    • m.route.mode
    • diff --git a/docs/mithril.route.md b/docs/mithril.route.md index d3fede4f..b32abdf6 100644 --- a/docs/mithril.route.md +++ b/docs/mithril.route.md @@ -276,7 +276,7 @@ redirects to `http://server/#/dashboard/marysue` [How to read signatures](how-to-read-signatures.md) ```clike -void route(String path [, any params]) +void route(String path [, any params] [, Boolean shouldReplaceHistory]) ``` - **String path** @@ -287,6 +287,10 @@ void route(String path [, any params]) Parameters to pass as a querystring +- **Boolean shouldReplaceHistory** + + If set to true, replaces the current history entry, instead of adding a new one. Defaults to false. + --- From 5bf0faf3574a033b3d418e616492918658e87326 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Mon, 9 Feb 2015 23:23:00 -0500 Subject: [PATCH 3/5] #453 fix html entity order bug in m.trust --- mithril.js | 2 +- tests/e2e/tests.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index e02b3049..a2bc57d9 100644 --- a/mithril.js +++ b/mithril.js @@ -209,7 +209,7 @@ var m = (function app(window, undefined) { //fix offset of next element if item was a trusted string w/ more than one html element //the first clause in the regexp matches elements //the second clause (after the pipe) matches text nodes - subArrayCount += (item.match(/<[^\/]|\>\s*[^<]/g) || []).length + subArrayCount += (item.match(/<[^\/]|\>\s*[^<]|&/g) || []).length } else subArrayCount += type.call(item) === ARRAY ? item.length : 1; cached[cacheCount++] = item diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js index ae1dff2a..7fb5183d 100644 --- a/tests/e2e/tests.js +++ b/tests/e2e/tests.js @@ -61,6 +61,14 @@ test('Mithril accessible as window.m', function() { ok(window.m) }) +test('m.trust w/ html entities', function() { + expect(1) + var view1 = m('div', "a", m.trust("&"), "b") + + m.render(dummyEl, view1) + equal(dummyEl.innerHTML, '
      a&b
      ', 'view1 rendered correctly') +}) + test('array item removal', function() { expect(2) var view1 = m('div', {}, [ From e0aa878fc1183a1cb7145c0e78e3e78e1df88a55 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Mon, 9 Feb 2015 23:24:26 -0500 Subject: [PATCH 4/5] add more elaborate test --- tests/e2e/tests.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js index 7fb5183d..1dd8de03 100644 --- a/tests/e2e/tests.js +++ b/tests/e2e/tests.js @@ -69,6 +69,14 @@ test('m.trust w/ html entities', function() { equal(dummyEl.innerHTML, '
      a&b
      ', 'view1 rendered correctly') }) +test('m.trust w/ html entities 2', function() { + expect(1) + var view1 = m('div', "a", m.trust("&"), "b", m.trust("&"), "c") + + m.render(dummyEl, view1) + equal(dummyEl.innerHTML, '
      a&b&c
      ', 'view1 rendered correctly') +}) + test('array item removal', function() { expect(2) var view1 = m('div', {}, [ From 6c130878447acdee1096b526312913360a6fc884 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Mon, 9 Feb 2015 23:27:31 -0500 Subject: [PATCH 5/5] #448 fix flatten edge case --- mithril.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mithril.js b/mithril.js index a2bc57d9..7c8b8e35 100644 --- a/mithril.js +++ b/mithril.js @@ -117,6 +117,7 @@ var m = (function app(window, undefined) { if (type.call(data[i]) === ARRAY) { data = data.concat.apply([], data); i-- //check current index again and flatten until there are no more nested arrays at that index + len = data.length } }