fix IE null ref exception
This commit is contained in:
parent
35d328f416
commit
50173f0e74
4 changed files with 15 additions and 8 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<!doctype html>
|
||||
<script src="http://polyfill.io"></script>
|
||||
<script src="../mithril.js"></script>
|
||||
<script src="test.js"></script>
|
||||
<script src="mock.js"></script>
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
if (!this.console) {
|
||||
var log = function(value) {document.write("<pre>" + value + "</pre>")}
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue