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

Function updateChildComponent

vue.js:4192–4272  ·  view source on GitHub ↗
(
        vm,// 虚拟dom vonde
        propsData, //props 数据属性
        listeners, //事件
        parentVnode, //父亲 虚拟dom vonde
        renderChildren)

Source from the content-addressed store, hash-verified

4190
4191 //更新子组件 循环props 把他们添加到观察者中 ,更新事件
4192 function updateChildComponent(
4193 vm,// 虚拟dom vonde
4194 propsData, //props 数据属性
4195 listeners, //事件
4196 parentVnode, //父亲 虚拟dom vonde
4197 renderChildren) { //子节点
4198 {
4199 isUpdatingChildComponent = true; //标志 是否已经更新过了子组件
4200 }
4201
4202
4203 // determine whether component has slot children 确定组件是否有槽子组件
4204 // we need to do this before overwriting $options._renderChildren 在覆盖$options._renderChildren之前,我们需要这样做
4205 //
4206 var hasChildren = !!(
4207 renderChildren || // has new static slots 是否有新的静态插槽
4208 vm.$options._renderChildren || // has old static slots 是否有旧的 静态插槽
4209 parentVnode.data.scopedSlots || // has new scoped slots 是否有范围插槽
4210 vm.$scopedSlots !== emptyObject // has old scoped slots 是否有旧的范围插槽 emptyObject 是一个空的对象
4211 );
4212
4213 vm.$options._parentVnode = parentVnode; //父亲 虚拟dom vonde
4214 vm.$vnode = parentVnode; // update vm's placeholder node without re-render 无需重新渲染即可更新vm的占位符节点
4215
4216 if (vm._vnode) { // update child tree's parent 更新子树的父树
4217 vm._vnode.parent = parentVnode;
4218 }
4219 vm.$options._renderChildren = renderChildren; //子节点
4220
4221 // update $attrs and $listeners hash
4222 // these are also reactive so they may trigger child update if the child
4223 // used them during render
4224 //更新$attrs和$listener散列
4225 //它们也是反应性的,因此如果子进程更新,它们可能触发子进程更新
4226 //渲染时使用它们
4227 vm.$attrs = parentVnode.data.attrs || emptyObject; //虚拟dom的属性
4228 vm.$listeners = listeners || emptyObject; //虚拟dom的 事件
4229
4230 // update props 更新props 属性
4231 if (propsData && vm.$options.props) {
4232 toggleObserving(false); // 标志是否禁止还是添加到观察者模式
4233 var props = vm._props; //获取属性对象
4234 var propKeys = vm.$options._propKeys || []; //获取属性的prop的key
4235 for (var i = 0; i < propKeys.length; i++) { //循环props属性
4236 var key = propKeys[i]; //获取props 单个 属性的key
4237 var propOptions = vm.$options.props; // wtf flow?
4238 /*
4239 验证支柱 验证 prosp 是否是规范数据 并且为props 添加 value.__ob__ 属性,把prosp添加到观察者中
4240 * 校验 props 参数 就是组建 定义的props 类型数据,校验类型
4241 *
4242 * 判断prop.type的类型是不是Boolean或者String,如果不是他们两类型,调用getPropDefaultValue获取默认值并且把value添加到观察者模式中
4243 */
4244 props[key] = validateProp(key, propOptions, propsData, vm);
4245 }
4246 toggleObserving(true);
4247
4248 // keep a copy of raw propsData
4249 //保留原始propsData的副本

Callers 1

vue.jsFile · 0.85

Calls 4

toggleObservingFunction · 0.85
validatePropFunction · 0.85
updateComponentListenersFunction · 0.85
resolveSlotsFunction · 0.85

Tested by

no test coverage detected