From cbdbdd7c60176796a10ff2d05d8cc907f5589d5b Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Tue, 9 Dec 2014 11:20:40 -0500 Subject: [PATCH] don't throw error when using console.log in firefox --- mithril.js | 2 +- tests/mithril-tests.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index f7a3ff5d..ff799287 100644 --- a/mithril.js +++ b/mithril.js @@ -91,7 +91,7 @@ var m = (function app(window, undefined) { //there's logic that relies on the assumption that null and undefined data are equivalent to empty strings //- this prevents lifecycle surprises from procedural helpers that mix implicit and explicit return statements (e.g. function foo() {if (cond) return m("div")} //- it simplifies diffing code - if (data == null) data = ""; + if (data == null || data.toString() == null) data = ""; if (data.subtree === "retain") return cached; var cachedType = type.call(cached), dataType = type.call(data); if (cached == null || cachedType !== dataType) { diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index 3b36aa3c..99e7bc95 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -795,6 +795,11 @@ function testMithril(mock) { m.render(root, m("div", [m("div", 1), null, [m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key:5}, 5)], [m("div", {key: 6}, 6)]])) return root.childNodes[0].childNodes.map(function(c) {return c.childNodes ? c.childNodes[0].nodeValue: c.nodeValue}).slice(0, 5).join("") == "13456" }) + test(function() { + var root = mock.document.createElement("div") + m.render(root, m("div", [console.log()])) //don't throw in Firefox + return true + }) //end m.render //m.redraw