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 #1253 (stale data on .prev() after replaceWith()) #1254

Merged
merged 4 commits into from Dec 12, 2020

Conversation

Gei0r
Copy link
Contributor

@Gei0r Gei0r commented Dec 3, 2018

Hi,
I fixed the error I described in #1253. I also modified two test cases to demonstrate the fix.

The problem was that in uniqueSplice(), the variable next was calculated wrongly:

  • Before: next pointed at spliceIdx, which actually containted the original node to be replaced. When it came to updating references in the linked list (line 104), the reference in the replaced element was changed. But the reference in the following element was not updated so it still pointed to the replaced element.
  • After: Now the prev reference in the element following the newly inserted element(s) is updated.

@fb55 fb55 linked an issue Dec 9, 2020 that may be closed by this pull request
@fb55 fb55 changed the base branch from master to v1.0.0 December 12, 2020 01:28
Copy link
Member

@fb55 fb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks for this!

@fb55 fb55 merged commit 4d5b9b0 into cheeriojs:v1.0.0 Dec 12, 2020
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.

Stale data in prev sibling after replaceWith()
2 participants