add test for issue 29

This commit is contained in:
Leo Horie 2014-04-08 22:17:19 -04:00
parent d684b0fceb
commit 1ed7fa5b30
7 changed files with 45 additions and 5 deletions

View file

@ -129,7 +129,7 @@ new function(window) {
cachedAttrs[attrName] = dataAttr
if (attrName === "config") continue
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node)
node[attrName] = autoredraw(dataAttr, node)
}
else if (attrName === "style") {
for (var rule in dataAttr) {
@ -679,6 +679,26 @@ function testMithril(mock) {
m.render(root, m("a", {config: m.route}, "test"))
return root.childNodes[0].childNodes[0].nodeValue === "test"
})
test(function() {
//see issue #29
var root = mock.document.createElement("div")
var list = [false, false]
m.render(root, list.reverse().map(function(flag, index) {
return m("input[type=checkbox]", {onclick: m.withAttr("checked", function(value) {list[index] = value}), checked: flag})
}))
mock.document.activeElement = root.childNodes[0]
root.childNodes[0].checked = true
root.childNodes[0].onclick({currentTarget: {checked: true}})
m.render(root, list.reverse().map(function(flag, index) {
return m("input[type=checkbox]", {onclick: m.withAttr("checked", function(value) {list[index] = value}), checked: flag})
}))
mock.document.activeElement = null
return root.childNodes[0].checked === false && root.childNodes[1].checked === true
})
//m.redraw
test(function() {

View file

@ -129,7 +129,7 @@ new function(window) {
cachedAttrs[attrName] = dataAttr
if (attrName === "config") continue
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node)
node[attrName] = autoredraw(dataAttr, node)
}
else if (attrName === "style") {
for (var rule in dataAttr) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -129,7 +129,7 @@ new function(window) {
cachedAttrs[attrName] = dataAttr
if (attrName === "config") continue
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node)
node[attrName] = autoredraw(dataAttr, node)
}
else if (attrName === "style") {
for (var rule in dataAttr) {

View file

@ -147,6 +147,26 @@ function testMithril(mock) {
m.render(root, m("a", {config: m.route}, "test"))
return root.childNodes[0].childNodes[0].nodeValue === "test"
})
test(function() {
//see issue #29
var root = mock.document.createElement("div")
var list = [false, false]
m.render(root, list.reverse().map(function(flag, index) {
return m("input[type=checkbox]", {onclick: m.withAttr("checked", function(value) {list[index] = value}), checked: flag})
}))
mock.document.activeElement = root.childNodes[0]
root.childNodes[0].checked = true
root.childNodes[0].onclick({currentTarget: {checked: true}})
m.render(root, list.reverse().map(function(flag, index) {
return m("input[type=checkbox]", {onclick: m.withAttr("checked", function(value) {list[index] = value}), checked: flag})
}))
mock.document.activeElement = null
return root.childNodes[0].checked === false && root.childNodes[1].checked === true
})
//m.redraw
test(function() {