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

Function initComponent

render/render.js:133–152  ·  view source on GitHub ↗
(vnode, hooks)

Source from the content-addressed store, hash-verified

131 }
132 }
133 function initComponent(vnode, hooks) {
134 var sentinel
135 if (typeof vnode.tag.view === "function") {
136 vnode.state = Object.create(vnode.tag)
137 sentinel = vnode.state.view
138 if (sentinel.$$reentrantLock$$ != null) return $emptyFragment
139 sentinel.$$reentrantLock$$ = true
140 } else {
141 vnode.state = void 0
142 sentinel = vnode.tag
143 if (sentinel.$$reentrantLock$$ != null) return $emptyFragment
144 sentinel.$$reentrantLock$$ = true
145 vnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === "function") ? new vnode.tag(vnode) : vnode.tag(vnode)
146 }
147 if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
148 initLifecycle(vnode.state, vnode, hooks)
149 vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))
150 if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument")
151 sentinel.$$reentrantLock$$ = null
152 }
153 function createComponent(parent, vnode, hooks, ns, nextSibling) {
154 initComponent(vnode, hooks)
155 if (vnode.instance != null) {

Callers 1

createComponentFunction · 0.70

Calls 1

initLifecycleFunction · 0.70

Tested by

no test coverage detected