Merge remote-tracking branch 'origin/rewrite' into rewrite
This commit is contained in:
commit
bb4321e8db
6 changed files with 78 additions and 70 deletions
|
|
@ -15,7 +15,7 @@ module.exports = function($window, redrawService) {
|
|||
current.component = component
|
||||
current.path = path
|
||||
current.resolve = null
|
||||
redrawService.render(root, current.render(Vnode(component, undefined, params)))
|
||||
redrawService.render(root, current.render.call(resolver, Vnode(component, undefined, params)))
|
||||
}
|
||||
var run = routeService.defineRoutes(routes, function(component, params, path, route, isAction) {
|
||||
if (component.view) render({}, component, params, path)
|
||||
|
|
@ -27,7 +27,7 @@ module.exports = function($window, redrawService) {
|
|||
render(component, resolved, params, path)
|
||||
}
|
||||
component.onmatch(function(resolved) {
|
||||
if (current.path !== path && current.resolve != null) current.resolve(resolved)
|
||||
if (current.resolve != null) current.resolve(resolved)
|
||||
}, params, path)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,25 +238,28 @@ o.spec("route", function() {
|
|||
}
|
||||
}
|
||||
|
||||
var resolver = {
|
||||
onmatch: function(resolve, args, requestedPath) {
|
||||
matchCount++
|
||||
|
||||
o(args.id).equals("abc")
|
||||
o(requestedPath).equals("/abc")
|
||||
o(this).equals(resolver)
|
||||
resolve(Component)
|
||||
},
|
||||
render: function(vnode) {
|
||||
renderCount++
|
||||
|
||||
o(vnode.attrs.id).equals("abc")
|
||||
o(this).equals(resolver)
|
||||
|
||||
return vnode
|
||||
},
|
||||
}
|
||||
|
||||
$window.location.href = prefix + "/abc"
|
||||
route(root, "/abc", {
|
||||
"/:id" : {
|
||||
onmatch: function(resolve, args, requestedPath) {
|
||||
matchCount++
|
||||
|
||||
o(args.id).equals("abc")
|
||||
o(requestedPath).equals("/abc")
|
||||
|
||||
resolve(Component)
|
||||
},
|
||||
render: function(vnode) {
|
||||
renderCount++
|
||||
|
||||
o(vnode.attrs.id).equals("abc")
|
||||
|
||||
return vnode
|
||||
},
|
||||
},
|
||||
"/:id" : resolver
|
||||
})
|
||||
|
||||
o(matchCount).equals(1)
|
||||
|
|
@ -514,21 +517,24 @@ o.spec("route", function() {
|
|||
|
||||
o("m.route.set(m.route.get()) re-runs the resolution logic (#1180)", function(done){
|
||||
var onmatch = o.spy(function(resolve) {resolve()})
|
||||
var render = o.spy(function(){return m("div")})
|
||||
|
||||
$window.location.href = prefix + "/"
|
||||
route(root, '/', {
|
||||
"/":{
|
||||
onmatch: onmatch,
|
||||
render: function(){return m("div")}
|
||||
render: render
|
||||
}
|
||||
})
|
||||
|
||||
o(onmatch.callCount).equals(1)
|
||||
o(render.callCount).equals(1)
|
||||
|
||||
route.set(route.get())
|
||||
|
||||
setTimeout(function() {
|
||||
o(onmatch.callCount).equals(2)
|
||||
o(render.callCount).equals(2)
|
||||
|
||||
done()
|
||||
}, FRAME_BUDGET)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue