fixing null reference when passing undefined to virtual dom tree

This commit is contained in:
Leo Horie 2014-03-20 15:36:52 -04:00
parent 960e9f2536
commit a7a9447cd6
8 changed files with 23 additions and 7 deletions

View file

@ -19,6 +19,8 @@ function testMithril(mock) {
test(function() {return m("div", ["a", "b"]).children.length === 2})
test(function() {return m("div", [m("div")]).children[0].tag === "div"})
test(function() {return m("div", m("div")).attrs.tag === "div"}) //yes, this is expected behavior: see method signature
test(function() {return m("div", [undefined]).tag === "div"})
test(function() {return m("div", [{foo: "bar"}])}) //as long as it doesn't throw errors, it's fine
//m.module
test(function() {
@ -98,6 +100,11 @@ function testMithril(mock) {
var elementAfter = root.childNodes[0]
return elementBefore !== elementAfter
})
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("div", [undefined]))
return root.childNodes[0].childNodes.length === 0
})
//m.redraw
test(function() {