Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 快速 Diff 代码逻辑错误导致未正确挂载新节点的问题 #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shaun931026
Copy link

据目前的实现,假设前置节点和后置节点都处理完,各只剩一个节点,分别是一个新增节点和一个删除节点,那么此时新增的节点不会被挂载。

// 此时节点 5 会被忽略
const prev = [1, 2, 3, 4]
const next = [1, 2, 5, 4]

将 moved 判断移入循环中使得 source 数组中 -1 的元素得以挂载。

@Telanx
Copy link

Telanx commented Nov 27, 2023

最后新节点待处理的分三种情况:
1.只有新增节点 2.只需要移动的节点,3.新增和移动
当不需要moved的时候,可以不走最长递增子序列算法

// if (moved) {
if (count > 0) {
        // const seq = lis(source)
        const seq = moved ?  lis(source) : []
        ...
}

This was referenced Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants