Skip to content

Commit b88e378

Browse files
committed
docs: add comment
1 parent feea42a commit b88e378

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/runtime-core/renderer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ export function createRenderer(options) {
538538
// 如果有 next 的话, 说明需要更新组件的数据(props,slots 等)
539539
// 先更新组件的数据,然后更新完成后,在继续对比当前组件的子元素
540540
if (next) {
541+
// 问题是 next 和 vnode 的区别是什么
542+
debugger;
541543
next.el = vnode.el;
542544
updateComponentPreRender(instance, next);
543545
}
@@ -577,11 +579,22 @@ export function createRenderer(options) {
577579
}
578580

579581
function updateComponentPreRender(instance, nextVNode) {
582+
// 更新 nextVNode 的组件实例
583+
// 现在 instance.vnode 是组件实例更新前的
584+
// 所以之前的 props 就是基于 instance.vnode.props 来获取
585+
// 接着需要更新 vnode ,方便下一次更新的时候获取到正确的值
586+
nextVNode.component = instance;
587+
// TODO 后面更新 props 的时候需要对比
588+
// const prevProps = instance.vnode.props;
589+
instance.vnode = nextVNode;
590+
instance.next = null;
591+
580592
const { props } = nextVNode;
581593
console.log("更新组件的 props", props);
582594
instance.props = props;
583595
console.log("更新组件的 slots");
584596
// TODO 更新组件的 slots
597+
// 需要重置 vnode
585598
}
586599

587600
return {

0 commit comments

Comments
 (0)