diff --git a/mithril.js b/mithril.js index d9ca2383..d417ff24 100644 --- a/mithril.js +++ b/mithril.js @@ -439,7 +439,8 @@ Mithril = m = new function app(window, undefined) { } m.prop = function (store) { - if ((isObj(store) || isFn(store)) && store !== null && isFn(store.then)) { + //note: using non-strict equality check here because we're checking if store is null OR undefined + if ((isObj(store) || isFn(store)) && store != null && isFn(store.then)) { return propify(store) } diff --git a/tests/index.html b/tests/index.html index 0db72d14..6e6064ea 100644 --- a/tests/index.html +++ b/tests/index.html @@ -1,4 +1,5 @@ + diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index 04aece02..1d379977 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -26,7 +26,7 @@ function testMithril(mock) { test(function() {return m("div", [{foo: "bar"}])}) //as long as it doesn't throw errors, it's fine test(function() {return m("svg", [m("g")])}) test(function() {return m("svg", [m("a[href='http://google.com']")])}) - test(function() {return m(".foo", {class: "bar"}).attrs.class == "foo bar"}) + test(function() {return m(".foo", {"class": "bar"}).attrs["class"] == "foo bar"}) test(function() {return m(".foo", {className: "bar"}).attrs.className == "foo bar"}) //m.module @@ -70,9 +70,9 @@ function testMithril(mock) { }) test(function() { var root = mock.document.createElement("div") - m.render(root, m("div", {class: "a"})) + m.render(root, m("div", {"class": "a"})) var elementBefore = root.childNodes[0] - m.render(root, m("div", {class: "b"})) + m.render(root, m("div", {"class": "b"})) var elementAfter = root.childNodes[0] return elementBefore === elementAfter }) @@ -701,8 +701,8 @@ function testMithril(mock) { test(function() { //https://github.com/lhorie/mithril.js/issues/157 var root = mock.document.createElement("div") - m.render(root, m("br", {class: "a"})) - m.render(root, m("br", {class: "aa"})) + m.render(root, m("br", {"class": "a"})) + m.render(root, m("br", {"class": "aa"})) return root.childNodes[0].childNodes.length == 0 }) test(function() { diff --git a/tests/test.js b/tests/test.js index a07a82b1..0eab457f 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,10 +1,15 @@ +if (!this.console) { + var log = function(value) {document.write("
" + value + "")} + this.console = {log: log, error: log} +} + function test(condition) { var duration = 0 var start = 0 var result = true test.total++ - if (typeof performance != "undefined") { + if (this.performance != null && performance.now) { start = performance.now() } try { @@ -15,7 +20,7 @@ function test(condition) { console.error(e) test.failures.push(condition) } - if (typeof performance != "undefined") { + if (this.performance != null && performance.now) { duration = performance.now() - start }