Skip to content

Commit

Permalink
docs: add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jan 4, 2022
1 parent feea42a commit b88e378
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/runtime-core/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ export function createRenderer(options) {
// 如果有 next 的话, 说明需要更新组件的数据(props,slots 等)
// 先更新组件的数据,然后更新完成后,在继续对比当前组件的子元素
if (next) {
// 问题是 next 和 vnode 的区别是什么
debugger;
next.el = vnode.el;
updateComponentPreRender(instance, next);
}
Expand Down Expand Up @@ -577,11 +579,22 @@ export function createRenderer(options) {
}

function updateComponentPreRender(instance, nextVNode) {
// 更新 nextVNode 的组件实例
// 现在 instance.vnode 是组件实例更新前的
// 所以之前的 props 就是基于 instance.vnode.props 来获取
// 接着需要更新 vnode ,方便下一次更新的时候获取到正确的值
nextVNode.component = instance;
// TODO 后面更新 props 的时候需要对比
// const prevProps = instance.vnode.props;
instance.vnode = nextVNode;
instance.next = null;

const { props } = nextVNode;
console.log("更新组件的 props", props);
instance.props = props;
console.log("更新组件的 slots");
// TODO 更新组件的 slots
// 需要重置 vnode
}

return {
Expand Down

0 comments on commit b88e378

Please sign in to comment.