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

Function createHTML

render/render.js:67–89  ·  view source on GitHub ↗
(parent, vnode, ns, nextSibling)

Source from the content-addressed store, hash-verified

65 }
66 var possibleParents = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}
67 function createHTML(parent, vnode, ns, nextSibling) {
68 var match = vnode.children.match(/^\s*?<(\w+)/im) || []
69 // not using the proper parent makes the child element(s) vanish.
70 // var div = document.createElement("div")
71 // div.innerHTML = "<td>i</td><td>j</td>"
72 // console.log(div.innerHTML)
73 // --> "ij", no <td> in sight.
74 var temp = $doc.createElement(possibleParents[match[1]] || "div")
75 if (ns === "http://www.w3.org/2000/svg") {
76 temp.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\">" + vnode.children + "</svg>"
77 temp = temp.firstChild
78 } else {
79 temp.innerHTML = vnode.children
80 }
81 vnode.dom = temp.firstChild
82 vnode.domSize = temp.childNodes.length
83 var fragment = $doc.createDocumentFragment()
84 var child
85 while (child = temp.firstChild) {
86 fragment.appendChild(child)
87 }
88 insertNode(parent, fragment, nextSibling)
89 }
90 function createFragment(parent, vnode, hooks, ns, nextSibling) {
91 var fragment = $doc.createDocumentFragment()
92 if (vnode.children != null) {

Callers 2

createNodeFunction · 0.70
updateHTMLFunction · 0.70

Calls 1

insertNodeFunction · 0.70

Tested by

no test coverage detected