MCPcopy
hub / github.com/ygs-code/vue / setScope

Function setScope

vue.js:8398–8425  ·  view source on GitHub ↗
(vnode)

Source from the content-addressed store, hash-verified

8396 //这是作为一种特殊情况来实现的,以避免开销
8397 //通过常规属性修补过程。
8398 function setScope(vnode) {
8399 var i;
8400 //fnScopeId 判断css作用 有没有设置Scope 如果有则设置 css作用域
8401 if (isDef(i = vnode.fnScopeId)) {
8402 nodeOps.setStyleScope(vnode.elm, i);
8403 } else {
8404 var ancestor = vnode;
8405 while (ancestor) {
8406 // context, /*编译作用域*/ 上下文 判断vnode 是否设置有作用于 与css是否设置有作用域 _scopeId 是放在dom属性上面做标记
8407 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
8408 //设置css作用域
8409 nodeOps.setStyleScope(vnode.elm, i);
8410 }
8411 //循环父节点
8412 ancestor = ancestor.parent;
8413 }
8414 }
8415 // for slot content they should also get the scopeId from the host instance.
8416 // 对于插槽内容,它们还应该从主机实例获得scopeId
8417 // activeInstance 可能是 vm
8418 if (isDef(i = activeInstance) &&
8419 i !== vnode.context &&
8420 i !== vnode.fnContext &&
8421 isDef(i = i.$options._scopeId)
8422 ) {
8423 nodeOps.setStyleScope(vnode.elm, i);
8424 }
8425 }
8426
8427
8428 function addVnodes(parentElm, //父亲节点

Callers 2

createElmFunction · 0.85
initComponentFunction · 0.85

Calls 1

isDefFunction · 0.85

Tested by

no test coverage detected