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

Function getStyle

vue.js:10689–10720  ·  view source on GitHub ↗

* parent component style should be after child's * so that parent component's style could override it * 父组件样式应该在子组件样式之后 * 这样父组件的样式就可以覆盖它 * 循环子组件和组件的样式,把它全部合并到一个样式对象中返回 样式对象 如{width:100px,height:200px} 返回该字符串。

(
        vnode, //虚拟dom
        checkChild //标志点 布尔值
    )

Source from the content-addressed store, hash-verified

10687 * 循环子组件和组件的样式,把它全部合并到一个样式对象中返回 样式对象 如{width:100px,height:200px} 返回该字符串。
10688 */
10689 function getStyle(
10690 vnode, //虚拟dom
10691 checkChild //标志点 布尔值
10692 ) {
10693 var res = {};
10694 var styleData; //style data
10695 if (checkChild) { // 标志点 布尔值
10696 var childNode = vnode; //获取子节点
10697 while (childNode.componentInstance) { //已经实例化过的 就是子节点有vonde
10698 childNode = childNode.componentInstance._vnode;
10699 if (
10700 childNode &&
10701 childNode.data &&
10702 (styleData = normalizeStyleData(childNode.data))
10703 ) {
10704 extend(res, styleData);
10705 }
10706 }
10707 }
10708
10709 if ((styleData = normalizeStyleData(vnode.data))) {
10710 extend(res, styleData);
10711 }
10712
10713 var parentNode = vnode;
10714 while ((parentNode = parentNode.parent)) {
10715 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
10716 extend(res, styleData);
10717 }
10718 }
10719 return res
10720 }
10721
10722 /* */
10723

Callers 1

updateStyleFunction · 0.85

Calls 2

normalizeStyleDataFunction · 0.85
extendFunction · 0.85

Tested by

no test coverage detected