You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* hook name | 所处阶段 | 参数
* pre | the patch process begins | none
* init | a vnode has been added | vnode
* create | a DOM element has been created based on a vnode | emptyVnode, vnode
* insert | an element has been inserted into the DOM | vnode
* update | an element is being updated | oldVnode, vnode
* destroy | an element is directly or indirectly being removed | vnode
* remove | an element is directly being removed from the DOM | vnode, removeCallback
* post | the patch process is done | none
*/
const hooks = ['pre', 'create', 'update', 'destroy', 'remove', 'post'];
const emptyNode = vnode('', '', {}, [], undefined, undefined);
function init(modules = [classModule, propsModule, styleModule], domApi) {
const cbs = collectCallbacksFromModules(modules);
return function patch(oldVnode, vnode) {};
}
const patch = init([
classModule,
propsModule,
styleModule
])
console.log('cbs', cbs);
脚本里调用patch, 来对比找出同级dom中不一样的地方,进行更新。
patch(container, vnode); 第一次把所有元素生成一个 vnode 然后 patch 到一个空 DOM 元素。
参考:解析 snabbdom 源码,教你实现精简的 Virtual DOM 库
h 和 patch 函数
h函数,生成vnode对象
console.log('vnode', vnode);
init得到patch函数
console.log('cbs', cbs);
脚本里调用patch, 来对比找出同级dom中不一样的地方,进行更新。
The text was updated successfully, but these errors were encountered: