re-render from scratch on route changes

This commit is contained in:
Leo Horie 2014-07-01 22:26:12 -04:00
parent 170d525aa5
commit d44176c888
3 changed files with 44 additions and 48 deletions

View file

@ -577,6 +577,32 @@ function testMithril(mock) {
m.render(root, m("textarea", ["test1"]))
return root.childNodes[0].value === "test1"
})
test(function() {
var root = mock.document.createElement("div")
var unloaded = 0
m.render(root, [
m("div", {
key: 1,
config: function(el, init, ctx) {
ctx.onunload = function() {
unloaded++
}
}
})
])
m.render(root, [
m("div", {key: 2}),
m("div", {
key: 1,
config: function(el, init, ctx) {
ctx.onunload = function() {
unloaded++
}
}
})
])
return unloaded == 0
})
//end m.render
//m.redraw
@ -1028,50 +1054,6 @@ function testMithril(mock) {
mock.performance.$elapse(50) //setup
mock.location.search = "?"
var root = mock.document.createElement("div")
var unloaded = 0
m.route.mode = "search"
m.route(root, "/", {
"/": {
controller: function() {},
view: function() {
return [
m("div", {
key: 1,
config: function(el, init, ctx) {
ctx.onunload = function() {
unloaded++
}
}
})
]
}
},
"/test19": {
controller: function() {},
view: function() {
return [
m("div", {
key: 1,
config: function(el, init, ctx) {
ctx.onunload = function() {
unloaded++
}
}
})
]
}
}
})
mock.performance.$elapse(50)
m.route("/test19")
mock.performance.$elapse(50) //teardown
return unloaded == 0
})
test(function() {
mock.performance.$elapse(50) //setup
mock.location.search = "?"
var root = mock.document.createElement("div")
var unloaded = 0
m.route.mode = "search"