Merge branch 'next' into perf

Conflicts:
	mithril.js
This commit is contained in:
Leo Horie 2014-12-12 09:20:49 -05:00
commit 6435a7c646
203 changed files with 35593 additions and 110 deletions

View file

@ -408,3 +408,14 @@ test("mixing trusted content w/ td", function() {
m.render(dummyEl, [m.trust("<td>1</td><td>2</td>"), m("i", "foo")])
equal(dummyEl.childNodes[1].nodeName, "I")
})
test("0 should not be treated as empty string", function() {
m.render(dummyEl, m("input", {value: ""}))
m.render(dummyEl, m("input", {value: 0}))
equal(dummyEl.childNodes[0].value, "0")
})
test("empty value in <option> should show as attribute", function() {
m.render(dummyEl, m("select", m("option", {value: ""}, "aaa")))
equal(dummyEl.childNodes[0].innerHTML, '<option value="">aaa</option>')
})

View file

@ -1,5 +1,5 @@
<!doctype html>
<script src="http://polyfill.io"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.3/es5-shim.min.js"></script>
<script src="test.js"></script>
<script src="mock.js"></script>
<script src="../mithril.js"></script>

View file

@ -780,6 +780,26 @@ function testMithril(mock) {
m.render(root, {foo: 123})
return root.childNodes.length == 0
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/299
var root = mock.document.createElement("div")
m.render(root, m("div", [m("div", {key: 1}, 1), m("div", {key: 2}, 2), m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key: 5}, 5), null, null, null, null, null, null, null, null, null, null]))
m.render(root, m("div", [null, null, m("div", {key: 3}, 3), null, null, m("div", {key: 6}, 6), null, null, m("div", {key: 9}, 9), null, null, m("div", {key: 12}, 12), null, null, m("div", {key: 15}, 15)]))
m.render(root, m("div", [m("div", {key: 1}, 1), m("div", {key: 2}, 2), m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key: 5}, 5), null, null, null, null, null, null, null, null, null, null]))
return root.childNodes[0].childNodes.map(function(c) {return c.childNodes ? c.childNodes[0].nodeValue: c.nodeValue}).slice(0, 5).join("") == "12345"
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/377
var root = mock.document.createElement("div")
m.render(root, m("div", [m("div", 1), m("div", 2), [m("div", {key: 3}, 3), m("div", {key: 4}, 4), m("div", {key:5}, 5)], [m("div", {key: 6}, 6)]]))
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

View file

@ -33,7 +33,7 @@ if (!Object.keys) {
}
var mock = {}
mock.window = new function() {
mock.window = (function() {
var window = {}
window.document = {}
window.document.childNodes = []
@ -136,7 +136,7 @@ mock.window = new function() {
callback()
}
}
window.XMLHttpRequest = new function() {
window.XMLHttpRequest = (function() {
var request = function() {
this.$headers = {}
this.setRequestHeader = function(key, value) {
@ -155,7 +155,7 @@ mock.window = new function() {
}
request.$instances = []
return request
}
}())
window.location = {search: "", pathname: "", hash: ""},
window.history = {}
window.history.pushState = function(data, title, url) {
@ -165,4 +165,4 @@ mock.window = new function() {
window.location.pathname = window.location.search = window.location.hash = url
}
return window
}
}())