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

Function createPatchFunction

vue.js:7926–9041  ·  view source on GitHub ↗
(backend)

Source from the content-addressed store, hash-verified

7924
7925 //创建虚拟dom
7926 function createPatchFunction(backend) {
7927 /*
7928 var nodeOps = Object.freeze({
7929 createElement: createElement$1, //创建一个真实的dom
7930 createElementNS: createElementNS, //创建一个真实的dom svg方式
7931 createTextNode: createTextNode, // 创建文本节点
7932 createComment: createComment, // 创建一个注释节点
7933 insertBefore: insertBefore, //插入节点 在xxx dom 前面插入一个节点
7934 removeChild: removeChild, //删除子节点
7935 appendChild: appendChild, //添加子节点 尾部
7936 parentNode: parentNode, //获取父亲子节点dom
7937 nextSibling: nextSibling, //获取下一个兄弟节点
7938 tagName: tagName, //获取dom标签名称
7939 setTextContent: setTextContent, // //设置dom 文本
7940 setStyleScope: setStyleScope //设置组建样式的作用域
7941 });
7942 modules=[
7943 attrs, // attrs包含两个方法create和update都是更新设置真实dom属性值 {create: updateAttrs, update: updateAttrs }
7944 klass, //klass包含类包含两个方法create和update都是更新calss。其实就是updateClass方法。 设置真实dom的class
7945 events, //更新真实dom的事件
7946 domProps, //更新真实dom的props 属性值
7947 style, // 更新真实dom的style属性。有两个方法create 和update 不过函数都是updateStyle更新真实dom的style属性值.将vonde虚拟dom的css 转义成并且渲染到真实dom的css中
7948 transition // 过度动画
7949 ref, //ref创建,更新 , 销毁 函数
7950 directives //自定义指令 创建 ,更新,销毁函数
7951 ]
7952 */
7953 console.log(backend)
7954
7955 var i, j;
7956 var cbs = {};
7957 console.log('==backend==')
7958 console.log(backend)
7959 var modules = backend.modules;
7960 var nodeOps = backend.nodeOps;
7961
7962
7963 // 把钩子函数添加到cbs队列中 循环数字 var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
7964 for (i = 0; i < hooks.length; ++i) {
7965 cbs[hooks[i]] = [];
7966 //循环modules 数组
7967 for (j = 0; j < modules.length; ++j) {
7968 //判断modules上面是否有定义有 'create', 'activate', 'update', 'remove', 'destroy'
7969 if (isDef(modules[j][hooks[i]])) {
7970 //如果有则把他添加到cbs 对象数组中
7971 cbs[hooks[i]].push(modules[j][hooks[i]]); //把钩子函数添加到cbs队列中
7972 }
7973 }
7974 }
7975 /*
7976 cbs={
7977 'create':[],
7978 'activate':[],
7979 'update':[],
7980 'remove':[],
7981 'destroy:[]
7982 }
7983 */

Callers 1

vue.jsFile · 0.85

Calls 14

isDefFunction · 0.85
makeMapFunction · 0.85
isUndefFunction · 0.85
invokeDestroyHookFunction · 0.85
createElmFunction · 0.85
sameVnodeFunction · 0.85
patchVnodeFunction · 0.85
isTrueFunction · 0.85
hydrateFunction · 0.85
invokeInsertHookFunction · 0.85
emptyNodeAtFunction · 0.85
isPatchableFunction · 0.85

Tested by

no test coverage detected