MCPcopy Index your code
hub / github.com/ygs-code/vue / initComponent

Function initComponent

vue.js:8224–8251  ·  view source on GitHub ↗
(
            vnode, //node 虚拟dom
            insertedVnodeQueue //插入Vnode队列 记录已经实例化过的组件
        )

Source from the content-addressed store, hash-verified

8222
8223 // 初始化组建,如果没有tag标签则去更新真实dom的属性,如果有tag标签,则注册或者删除ref 然后为insertedVnodeQueue.push(vnode);确保调用插入钩子如果vnode.data.pendingInsert为反正则也为insertedVnodeQueue插入缓存 vnode.data.pendingInsert
8224 function initComponent(
8225 vnode, //node 虚拟dom
8226 insertedVnodeQueue //插入Vnode队列 记录已经实例化过的组件
8227 ) {
8228 if (isDef(vnode.data.pendingInsert)) { //模板缓存 待插入
8229 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
8230 vnode.data.pendingInsert = null;
8231 }
8232 vnode.elm = vnode.componentInstance.$el; //组件实例
8233 if (isPatchable(vnode)) { // 判断组件是否定义有 tag标签
8234 //invokeCreateHooks,循环cbs.create 钩子函数,并且执行调用,其实cbs.create 钩子函数就是platformModules中的attrs中 updateAttrs更新属性函数。如果是组件则调用componentVNodeHooks中的 create
8235 invokeCreateHooks(vnode, insertedVnodeQueue);
8236 //为有作用域的CSS设置作用域id属性。
8237 //这是作为一种特殊情况来实现的,以避免开销
8238 //通过常规属性修补过程。
8239 setScope(vnode);
8240 } else {
8241 // empty component root.
8242 // skip all element-related modules except for ref (#3455)
8243 //空组件根。
8244 //跳过除ref(#3455)之外的所有与元素相关的模块
8245 //注册ref
8246 registerRef(vnode);
8247 // make sure to invoke the insert hook
8248 //确保调用插入钩子
8249 insertedVnodeQueue.push(vnode);
8250 }
8251 }
8252
8253 //激活组建。把vonde添加到parentElm中。如果是transition组件则 调用 transition中的activate就是_enter
8254 function reactivateComponent(

Callers 2

createComponentFunction · 0.85
hydrateFunction · 0.85

Calls 5

isDefFunction · 0.85
isPatchableFunction · 0.85
invokeCreateHooksFunction · 0.85
setScopeFunction · 0.85
registerRefFunction · 0.85

Tested by

no test coverage detected