fix back button on default route trigger
This commit is contained in:
parent
a2680b30a4
commit
084d99f125
2 changed files with 42 additions and 3 deletions
|
|
@ -22,8 +22,8 @@ module.exports = function($window, renderer, pubsub) {
|
||||||
else {
|
else {
|
||||||
renderer.render(root, Node(payload, null, args, undefined, undefined, undefined))
|
renderer.render(root, Node(payload, null, args, undefined, undefined, undefined))
|
||||||
}
|
}
|
||||||
}, function() {
|
}, function(path, params) {
|
||||||
router.setPath(defaultRoute)
|
router.setPath(defaultRoute, null, {replace: true})
|
||||||
})
|
})
|
||||||
autoredraw(root, renderer, pubsub, replay)
|
autoredraw(root, renderer, pubsub, replay)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,45 @@ o.spec("route", function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
o("default route doesn't break back button", function(done) {
|
||||||
|
$window.location.href = "http://google.com"
|
||||||
|
route(root, "/a", {
|
||||||
|
"/a" : {
|
||||||
|
view: function() {
|
||||||
|
return m("div")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
o(root.firstChild.nodeName).equals("DIV")
|
||||||
|
|
||||||
|
$window.history.back()
|
||||||
|
|
||||||
|
o($window.location.pathname).equals("/")
|
||||||
|
|
||||||
|
done()
|
||||||
|
}, FRAME_BUDGET)
|
||||||
|
})
|
||||||
|
|
||||||
|
o("default route does not inherit params", function(done) {
|
||||||
|
$window.location.href = "/invalid?foo=bar"
|
||||||
|
route(root, "/a", {
|
||||||
|
"/a" : {
|
||||||
|
oninit: init,
|
||||||
|
view: function() {
|
||||||
|
return m("div")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function init(vnode) {
|
||||||
|
o(vnode.attrs).deepEquals({})
|
||||||
|
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
o("redraws when render function is executed", function(done) {
|
o("redraws when render function is executed", function(done) {
|
||||||
var onupdate = o.spy()
|
var onupdate = o.spy()
|
||||||
var oninit = o.spy()
|
var oninit = o.spy()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue