#413 fix ctx.retain bug

This commit is contained in:
Leo Horie 2015-03-13 22:54:46 -04:00
parent 780f52a4a6
commit 8cc4a862fe
2 changed files with 24 additions and 3 deletions

View file

@ -274,7 +274,7 @@ var m = (function app(window, undefined) {
}
//schedule configs to be called. They are called after `build` finishes running
if (typeof data.attrs["config"] === FUNCTION) {
var context = cached.configContext = cached.configContext || {retain: m.redraw.strategy() == "diff"};
var context = cached.configContext = cached.configContext || {retain: (m.redraw.strategy() == "diff") || undefined};
// bind
var callback = function(data, args) {

View file

@ -98,6 +98,27 @@ function testMithril(mock) {
return unloaded === true
})
test(function() {
mock.requestAnimationFrame.$resolve()
var root = mock.document.createElement("div")
var initCount = 0
var module = {}
module.view = function() {
return m("div", {config: function(el, init) {
if (!init) initCount++
}})
}
m.module(root, module)
mock.requestAnimationFrame.$resolve()
m.redraw()
mock.requestAnimationFrame.$resolve()
return initCount == 1
})
m.redraw.strategy(undefined) //teardown for m.module tests
//m.withAttr
@ -1803,7 +1824,7 @@ function testMithril(mock) {
"/a": a
})
return value === false
return !value
})
test(function() {
mock.requestAnimationFrame.$resolve()
@ -1824,7 +1845,7 @@ function testMithril(mock) {
"/a": a
})
return value === true
return value
})
test(function() {
mock.requestAnimationFrame.$resolve()