m.route supports params as an object, and builds querystring from it
m.route('/path', {param: 1}) => navigates to '/path?param=1'
The API is a little bit problematic, as it is not possible to combine it with `shouldReplaceHistoryEntry`.
This commit is contained in:
parent
001263080e
commit
5b6b7de045
2 changed files with 27 additions and 9 deletions
|
|
@ -635,6 +635,21 @@ function testMithril(mock) {
|
|||
mock.performance.$elapse(50) //teardown
|
||||
return true; mock.location.search == path && paramValue.a == "foo" && paramValue.b.c == "1" && paramValue.b.d == "2" && m.route.param("str") == "bar"
|
||||
})
|
||||
test(function() {
|
||||
mock.performance.$elapse(50) //setup
|
||||
mock.location.search = "?"
|
||||
|
||||
var root = mock.document.createElement("div")
|
||||
m.route.mode = "search"
|
||||
m.route(root, "/", {
|
||||
"/": {controller: function() {}, view: function() {return "bar"}},
|
||||
"/test12": {controller: function() {}, view: function() {return m.route.param("test") + "_" + m.route.param("test2")}}
|
||||
})
|
||||
mock.performance.$elapse(50)
|
||||
m.route("/test12?test=foo", {test2: "bar"})
|
||||
mock.performance.$elapse(50) //teardown
|
||||
return mock.location.search == "?/test12?test=foo&test2=bar" && root.childNodes[0].nodeValue === "foo_bar"
|
||||
})
|
||||
//end m.route
|
||||
|
||||
//m.prop
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue