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

HTML API: Fix case where updates are overlooked when seeking to earlier locations. #4345

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Apr 19, 2023

Trac ticket #58160-trac

In certain cases when seeking to an earlier location in a document after changes have been enqueued, the tag processor will lose the earlier changes.

In this patch we're fixing the bug so that it properly retains the changes that were applied before the call to seek().

The problem was that when changes had already been applied and no more were enqueued, the tag processor was returning the updated HTML without updating its internal state to reflect that. This was probably an optimization for that case but I can't remember exactly why it doesn't update the internal pointers (@adamziel maybe you remember?). The fix is simple: mirror the second case and update the internal pointers.

Copy link
Contributor

@adamziel adamziel left a comment

Choose a reason for hiding this comment

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

I can't remember exactly why it doesn't update the internal pointers (@adamziel maybe you remember?)

An oversight probably. This is a good fix!

@dmsnell dmsnell closed this Apr 21, 2023
@dmsnell dmsnell deleted the html-api/fix-lost-content-after-skipping-ahead branch April 21, 2023 13:34
@dmsnell
Copy link
Member Author

dmsnell commented Apr 21, 2023

Merged in 55675

dmsnell added a commit to WordPress/gutenberg that referenced this pull request Apr 24, 2023
 - Support a few extra invalid comment syntaxes. WordPress/wordpress-develop#4256
 - Invalidate bookmarks which have been eliminated by enqueued changes. WordPress/wordpress-develop#4116
 - Expose whether the currently-matched tag has the self-closing flag. WordPress/wordpress-develop#4266
 - Avoid double-writing an attribute value if given case-variations of the name. WordPress/wordpress-develop#4337
 - Linting updates from WordPress/wordpress-develop#4360.
 - Avoid losing previous updates in certain cases when seeking earlier in a document. WordPress/wordpress-develop#4345
@ockham
Copy link
Contributor

ockham commented May 3, 2023

Backported to the 6.2 branch in r55707.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants