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.
+
---
diff --git a/mithril.js b/mithril.js
index 5ca89f85..cfa2ae95 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
}
}
@@ -209,7 +210,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
@@ -1032,7 +1033,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])
diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js
index ae1dff2a..1dd8de03 100644
--- a/tests/e2e/tests.js
+++ b/tests/e2e/tests.js
@@ -61,6 +61,22 @@ 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('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', {}, [