Merge branch 'next' into components
This commit is contained in:
commit
bd771ab0b4
4 changed files with 25 additions and 4 deletions
|
|
@ -35,7 +35,7 @@
|
|||
<li><a href="mithril.route.html" title="A routing utility">m.route</a>
|
||||
<ul>
|
||||
<li><a href="mithril.route.html#defining-routes" title="Defines what routes exist">m.route(rootElement, defaultRoute, routes)</a></li>
|
||||
<li><a href="mithril.route.html#redirecting" title="Redirects to a route">m.route(path, params)</a></li>
|
||||
<li><a href="mithril.route.html#redirecting" title="Redirects to a route">m.route(path, params, replaceHistory)</a></li>
|
||||
<li><a href="mithril.route.html#reading-current-route" title="Read the current route">m.route()</a></li>
|
||||
<li><a href="mithril.route.html#mode-abstraction" title="Routing mode abstraction">m.route(element)</a></li>
|
||||
<li><a href="mithril.route.html#mode" title="Whether routing uses location hash, querystring or pathname">m.route.mode</a></li>
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
---
|
||||
|
||||
<a name="reading-current-route"></a>
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -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, '<div>a&b</div>', '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, '<div>a&b&c</div>', 'view1 rendered correctly')
|
||||
})
|
||||
|
||||
test('array item removal', function() {
|
||||
expect(2)
|
||||
var view1 = m('div', {}, [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue