Merge pull request #1324 from pygy/rewrite-fix-router-keys
[rewrite] respect keys on routed components.
This commit is contained in:
commit
c4c0f3934e
2 changed files with 27 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ module.exports = function($window, mount) {
|
||||||
var currentResolve, currentComponent, currentRender, currentArgs, currentPath
|
var currentResolve, currentComponent, currentRender, currentArgs, currentPath
|
||||||
|
|
||||||
var RouteComponent = {view: function() {
|
var RouteComponent = {view: function() {
|
||||||
return currentRender(Vnode(currentComponent, null, currentArgs, undefined, undefined, undefined))
|
return [currentRender(Vnode(currentComponent, null, currentArgs, undefined, undefined, undefined))]
|
||||||
}}
|
}}
|
||||||
function defaultRender(vnode) {
|
function defaultRender(vnode) {
|
||||||
return vnode
|
return vnode
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,32 @@ o.spec("route", function() {
|
||||||
o(root.firstChild.nodeName).equals("DIV")
|
o(root.firstChild.nodeName).equals("DIV")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
o("changing `vnode.key` in `render` resets the component", function(done, timeout){
|
||||||
|
timeout(FRAME_BUDGET * 3)
|
||||||
|
|
||||||
|
var oninit = o.spy()
|
||||||
|
var Component = {
|
||||||
|
oninit: oninit,
|
||||||
|
view: function(){
|
||||||
|
return m("div")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$window.location.href = prefix + "/abc"
|
||||||
|
route(root, "/abc", {
|
||||||
|
"/:id": {render: function(vnode) {
|
||||||
|
return m(Component, {key: vnode.attrs.id})
|
||||||
|
}}
|
||||||
|
})
|
||||||
|
setTimeout(function(){
|
||||||
|
o(oninit.callCount).equals(1)
|
||||||
|
route.set('/def')
|
||||||
|
setTimeout(function(){
|
||||||
|
o(oninit.callCount).equals(2)
|
||||||
|
done()
|
||||||
|
}, FRAME_BUDGET)
|
||||||
|
}, FRAME_BUDGET)
|
||||||
|
})
|
||||||
|
|
||||||
o("accepts RouteResolver without `onmatch` method as payload", function() {
|
o("accepts RouteResolver without `onmatch` method as payload", function() {
|
||||||
var renderCount = 0
|
var renderCount = 0
|
||||||
var Component = {
|
var Component = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue