test retain flag

This commit is contained in:
Leo Horie 2015-03-06 08:58:06 -05:00
parent eb8fa6f1c3
commit bf32eb7dfc

View file

@ -2589,6 +2589,44 @@ function testMithril(mock) {
return initCount == 1
})
test(function() {
//retain flag should work inside component
mock.requestAnimationFrame.$resolve()
mock.location.search = "?"
var root = mock.document.createElement("div")
var initCount = 0
var a = {}
a.controller = function() {}
a.view = function() {
return m("div", m("a", {config: function(el, init, ctx) {
ctx.retain = true
if (!init) initCount++
}}))
}
var b = {}
b.controller = function() {m.redraw.strategy("diff")}
b.view = function() {
return m("section", m("a", {config: function(el, init, ctx) {
ctx.retain = true
if (!init) initCount++
}}))
}
m.route(root, "/a", {
"/a": {view: function() {return m("div", a)}},
"/b": {view: function() {return m("div", b)}},
})
mock.requestAnimationFrame.$resolve()
m.route("/b")
mock.requestAnimationFrame.$resolve()
return initCount == 1
})
//end m.route
//m.prop