Merge branch 'rewrite' into multi-mount-test
This commit is contained in:
commit
e43d638f54
15 changed files with 515 additions and 194 deletions
|
|
@ -6,7 +6,7 @@ module.exports = function(root, renderer, pubsub, callback) {
|
|||
var run = throttle(callback)
|
||||
if (renderer != null) {
|
||||
renderer.setEventCallback(function(e) {
|
||||
if (e.redraw !== false) run()
|
||||
if (e.redraw !== false) pubsub.publish()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module.exports = function($window, renderer, pubsub) {
|
|||
renderer.render(root, Node(payload, null, args, undefined, undefined, undefined))
|
||||
}
|
||||
}, function() {
|
||||
router.setPath(defaultRoute)
|
||||
router.setPath(defaultRoute, null, {replace: true})
|
||||
})
|
||||
autoredraw(root, renderer, pubsub, replay)
|
||||
}
|
||||
|
|
@ -31,6 +31,6 @@ module.exports = function($window, renderer, pubsub) {
|
|||
route.prefix = router.setPrefix
|
||||
route.set = router.setPath
|
||||
route.get = router.getPath
|
||||
|
||||
|
||||
return route
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
var onupdate = o.spy()
|
||||
var oninit = o.spy()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue