fix undefined diff case without breaking void element case
This commit is contained in:
parent
39a0c1e63b
commit
f64d861552
1 changed files with 4 additions and 3 deletions
|
|
@ -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|TRACK|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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue