Check for arguments object edge case, and remove instanceof

This commit is contained in:
Richard Eames 2014-09-18 12:37:22 -06:00
parent f3018776b8
commit c56f75a4c3
2 changed files with 13 additions and 3 deletions

View file

@ -22,7 +22,8 @@ Mithril = m = new function app(window, undefined) {
*
*/
function m() {
var args = Array.prototype.slice.call(arguments, 0)
var arrSlice = Array.prototype.slice;
var args = arrSlice.call(arguments, 0)
var hasAttrs = args[1] != null && isObj(args[1]) && !("tag" in args[1]) && !("subtree" in args[1])
var attrs = hasAttrs ? args[1] : {}
var classAttrName = "class" in attrs ? "class" : "className"
@ -41,8 +42,8 @@ Mithril = m = new function app(window, undefined) {
var children = hasAttrs ? args[2] : args[1]
if (children instanceof Array) {
cell.children = children
if (isArr(children) || type(children) == "[object Arguments]") {
cell.children = arrSlice.call(children, 0)
}
else {
cell.children = hasAttrs ? args.slice(2) : args.slice(1)

View file

@ -784,6 +784,15 @@ function testMithril(mock) {
m.render(root, [m("div.green", [m("div")]), m("div.blue")])
return root.childNodes.length == 2
})
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("ul", [m("li")]))
var change = function() {
m.render(root, m("ul", arguments))
}
change(m("b"));
return root.childNodes[0].childNodes[0].nodeName == "B"
})
//end m.render
//m.redraw