MCPcopy Create free account
hub / github.com/ygs-code/vue / genClassForVnode

Function genClassForVnode

vue.js:7487–7505  ·  view source on GitHub ↗
(vnode)

Source from the content-addressed store, hash-verified

7485 * class 转码获取vonde 中的staticClass 静态class 和class动态class转义成真实dom需要的class格式。然后返回class字符串
7486 * */
7487 function genClassForVnode(vnode) {
7488 var data = vnode.data; //获取vnode.data 数据 标签属性数据
7489 var parentNode = vnode; //获取 父节点
7490 var childNode = vnode; //获取子节点
7491 // this.componentInstance = undefined; /*当前节点对应的组件的实例*/
7492 while (isDef(childNode.componentInstance)) { //如果定义了componentInstance 组件实例 递归合并子组件的class
7493 childNode = childNode.componentInstance._vnode; //上一个vnode
7494 if (childNode && childNode.data) {
7495 data = mergeClassData(childNode.data, data);
7496 }
7497 }
7498 while (isDef(parentNode = parentNode.parent)) { //递归父组件parent 合并父组件class
7499 if (parentNode && parentNode.data) {
7500 //合并calss数据
7501 data = mergeClassData(data, parentNode.data);
7502 }
7503 }
7504 return renderClass(data.staticClass, data.class) //渲染calss
7505 }
7506
7507 //合并calss数据
7508 function mergeClassData(child, parent) {

Callers 1

updateClassFunction · 0.85

Calls 3

isDefFunction · 0.85
mergeClassDataFunction · 0.85
renderClassFunction · 0.85

Tested by

no test coverage detected