diff --git a/mithril.js b/mithril.js index 81331ce4..8af1bc28 100644 --- a/mithril.js +++ b/mithril.js @@ -1,6 +1,7 @@ Mithril = m = new function app(window, undefined) { var type = {}.toString var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g, attrParser = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/ + var voidElements = /AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TR‌​ACK|WBR/ function m() { var args = arguments @@ -163,7 +164,7 @@ Mithril = m = new function app(window, undefined) { cached = { tag: data.tag, //process children before attrs so that select.value works correctly - children: data.children != null ? build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs) : undefined, + children: build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs), attrs: setAttributes(node, data.tag, data.attrs, {}, namespace), nodes: [node] } @@ -172,7 +173,7 @@ Mithril = m = new function app(window, undefined) { else { node = cached.nodes[0] setAttributes(node, data.tag, data.attrs, cached.attrs, namespace) - cached.children = data.children != null ? build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs) : undefined + cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs) cached.nodes.intact = true if (shouldReattach === true && node != null) parentElement.insertBefore(node, parentElement.childNodes[index] || null) } @@ -190,7 +191,7 @@ Mithril = m = new function app(window, undefined) { } else { nodes = [window.document.createTextNode(data)] - parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null) + if (!parentElement.nodeName.match(voidElements)) parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null) } cached = "string number boolean".indexOf(typeof data) > -1 ? new data.constructor(data) : data cached.nodes = nodes