Check that the 2nd argument to m.route is a string
This commit is contained in:
parent
e94a0a7c22
commit
c3d3fa7315
2 changed files with 33 additions and 1 deletions
|
|
@ -517,7 +517,7 @@ Mithril = m = new function app(window, undefined) {
|
||||||
var redirect = function() {}, routeParams = {}, currentRoute
|
var redirect = function() {}, routeParams = {}, currentRoute
|
||||||
m.route = function() {
|
m.route = function() {
|
||||||
if (arguments.length === 0) return currentRoute
|
if (arguments.length === 0) return currentRoute
|
||||||
else if (arguments.length === 3 && typeof arguments[1] == "string") {
|
else if (arguments.length === 3 && isStr(arguments[1])) {
|
||||||
var root = arguments[0], defaultRoute = arguments[1], router = arguments[2]
|
var root = arguments[0], defaultRoute = arguments[1], router = arguments[2]
|
||||||
redirect = function(source) {
|
redirect = function(source) {
|
||||||
var path = currentRoute = normalizeRoute(source)
|
var path = currentRoute = normalizeRoute(source)
|
||||||
|
|
|
||||||
|
|
@ -1525,6 +1525,38 @@ function testMithril(mock) {
|
||||||
mock.requestAnimationFrame.$resolve() //teardown
|
mock.requestAnimationFrame.$resolve() //teardown
|
||||||
return mock.location.search == "?/test23/" && root.childNodes[0].nodeValue === "bar"
|
return mock.location.search == "?/test23/" && root.childNodes[0].nodeValue === "bar"
|
||||||
})
|
})
|
||||||
|
test(function() {
|
||||||
|
mock.requestAnimationFrame.$resolve() //setup
|
||||||
|
mock.location.search = "?"
|
||||||
|
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
var value
|
||||||
|
m.route(root, String("/foo+bar"), {
|
||||||
|
"/:arg": {
|
||||||
|
controller: function() {value = m.route.param("arg")},
|
||||||
|
view: function(ctrl) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return value == "foo+bar"
|
||||||
|
})
|
||||||
|
test(function() {
|
||||||
|
mock.requestAnimationFrame.$resolve() //setup
|
||||||
|
mock.location.search = "?"
|
||||||
|
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
var value
|
||||||
|
m.route(root, new String("/foo+bar"), {
|
||||||
|
"/:arg": {
|
||||||
|
controller: function() {value = m.route.param("arg")},
|
||||||
|
view: function(ctrl) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return value == "foo+bar"
|
||||||
|
})
|
||||||
//end m.route
|
//end m.route
|
||||||
|
|
||||||
//m.prop
|
//m.prop
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue