From f3018776b8d0ae1f4746aaf3a664271b40b1eddc Mon Sep 17 00:00:00 2001 From: Richard Eames Date: Thu, 18 Sep 2014 12:04:02 -0600 Subject: [PATCH] Check for weird edge-case & tests --- mithril.js | 2 +- tests/mithril-tests.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index a85b490a..e20ef884 100644 --- a/mithril.js +++ b/mithril.js @@ -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 diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index 6d293b74..9a8cf482 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -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")])]))