Check for weird edge-case & tests

This commit is contained in:
Richard Eames 2014-09-18 12:04:02 -06:00
parent c3d3fa7315
commit f3018776b8
2 changed files with 13 additions and 1 deletions

View file

@ -194,7 +194,7 @@ Mithril = m = new function app(window, undefined) {
clear(cached.nodes)
if (cached.configContext && isFn(cached.configContext.onunload)) cached.configContext.onunload()
}
if (typeof data.tag != "string") return
if (!isStr(data.tag)) return
var node, isNew = cached.nodes.length === 0
if (data.attrs.xmlns) namespace = data.attrs.xmlns

View file

@ -154,6 +154,18 @@ function testMithril(mock) {
m.render(root, m("ul", [{}]))
return root.childNodes[0].childNodes.length === 0
})
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("ul", [m("li")]))
m.render(root, m("ul", [{tag: "b", attrs: {}}]))
return root.childNodes[0].childNodes[0].nodeName == "B"
})
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("ul", [m("li")]))
m.render(root, m("ul", [{tag: new String("b"), attrs: {}}]))
return root.childNodes[0].childNodes[0].nodeName == "B"
})
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("ul", [m("li", [m("a")])]))