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

不必要的insertBefore导致dom原地插入,造成滚动丢失 #9

Closed
BetaSu opened this issue Nov 3, 2020 · 1 comment · Fixed by #10
Closed

不必要的insertBefore导致dom原地插入,造成滚动丢失 #9

BetaSu opened this issue Nov 3, 2020 · 1 comment · Fixed by #10
Labels
bug Something isn't working released

Comments

@BetaSu
Copy link
Collaborator

BetaSu commented Nov 3, 2020

bug描述
当非HostComponent触发更新, commit阶段insertElement方法中,如果是如下结构:

<div>
    <List/>
    <p>我是谁不重要,关键是占了个位置</p>
</div>

由于afterp对应DOM,会进入如下逻辑并返回,所以不会造成DOM更新

 if (after === null && dom === parent.lastChild) {
      return;
 }

但当是如下结构时会进入insertBefore造成List对应DOM原地插入。

<div>
    <List/>
</div>

为了解决这个bug,增加如下跳出条件:

// 如果目标dom的nextSibling和他已经存在的after相同,则跳出
 if (dom.nextSibling && dom.nextSibling === after) {
      return;
 }
@BetaSu BetaSu added the bug Something isn't working label Nov 3, 2020
@BetaSu BetaSu mentioned this issue Nov 3, 2020
lizheming pushed a commit that referenced this issue Nov 3, 2020
lizheming pushed a commit that referenced this issue Nov 3, 2020
## [1.7.4](v1.7.3...v1.7.4) (2020-11-03)

### Bug Fixes

* [#9](#9) ([#10](#10)) ([66b077d](66b077d))
@lizheming
Copy link
Collaborator

🎉 This issue has been resolved in version 1.7.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants