MCPcopy
hub / github.com/MithrilJS/mithril.js / updateElement

Function updateElement

render/render.js:479–502  ·  view source on GitHub ↗
(old, vnode, hooks, ns)

Source from the content-addressed store, hash-verified

477 }
478 }
479 function updateElement(old, vnode, hooks, ns) {
480 var element = vnode.dom = old.dom
481 ns = getNameSpace(vnode) || ns
482
483 if (vnode.tag === "textarea") {
484 if (vnode.attrs == null) vnode.attrs = {}
485 if (vnode.text != null) {
486 vnode.attrs.value = vnode.text //FIXME handle multiple children
487 vnode.text = undefined
488 }
489 }
490 updateAttrs(vnode, old.attrs, vnode.attrs, ns)
491 if (vnode.attrs != null && vnode.attrs.contenteditable != null) {
492 setContentEditable(vnode)
493 }
494 else if (old.text != null && vnode.text != null && vnode.text !== "") {
495 if (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text
496 }
497 else {
498 if (old.text != null) old.children = [Vnode("#", undefined, undefined, old.text, undefined, old.dom.firstChild)]
499 if (vnode.text != null) vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)]
500 updateNodes(element, old.children, vnode.children, hooks, null, ns)
501 }
502 }
503 function updateComponent(parent, old, vnode, hooks, nextSibling, ns) {
504 vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))
505 if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument")

Callers 1

updateNodeFunction · 0.70

Calls 5

getNameSpaceFunction · 0.70
updateAttrsFunction · 0.70
setContentEditableFunction · 0.70
VnodeFunction · 0.70
updateNodesFunction · 0.70

Tested by

no test coverage detected