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: Preserve internal cursor across updates. #4371

Closed

Commits on Apr 23, 2023

  1. HTML API: Accumulate shift for internal parsing pointer.

    While working on WordPress/block-interactivity-experiments#141 @ockham
    discovered that the Tag Processor was making a small mistake. After
    making some updates the parser wasn't returning to the start of the
    affected tag. A test case was created in WordPress#4355.
    
    In few words, the Tag Processor has not been treating its own internal
    pointer `bytes_already_parsed` the same way it treats its bookmarks.
    That is, when updates are applied to the input document and then
    `get_updated_html()` is called, the internal pointer transfers to
    the newly-updated content as if no updates had been applied since
    the previous call to `get_updated_html()`.
    
    In this patch we're creating a new "shift accumulator" to account for
    all of the updates that accrue before calling `get_updated_html()`.
    This accumulated shift will be applied when swapping the input document
    with the output buffer, which should result in the pointer pointing to
    the same logical spot in the document it did before the udpate.
    
    In effect this patch adds a single workaround for treating the
    internal pointer like a bookmark, plus a temporary pointer which points
    to the beginning of the current tag when calling `get_updated_html()`.
    This will preserve the assumption that updating a document doesn't
    move that pointer, or shift which tag is currently matched.
    dmsnell committed Apr 23, 2023
    Configuration menu
    Copy the full SHA
    7085970 View commit details
    Browse the repository at this point in the history
  2. Update code, docblocks

    dmsnell committed Apr 23, 2023
    Configuration menu
    Copy the full SHA
    61346f5 View commit details
    Browse the repository at this point in the history
  3. Code refactor

    dmsnell committed Apr 23, 2023
    Configuration menu
    Copy the full SHA
    55ead4f View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2023

  1. Configuration menu
    Copy the full SHA
    fb99257 View commit details
    Browse the repository at this point in the history
  2. Fix from last refactor

    dmsnell committed Apr 24, 2023
    Configuration menu
    Copy the full SHA
    d0f8d50 View commit details
    Browse the repository at this point in the history
  3. Docs and names updates.

    dmsnell committed Apr 24, 2023
    Configuration menu
    Copy the full SHA
    3c731b5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fb4e512 View commit details
    Browse the repository at this point in the history
  5. Rearrange code for clarity

    dmsnell committed Apr 24, 2023
    Configuration menu
    Copy the full SHA
    a31fc01 View commit details
    Browse the repository at this point in the history
  6. Linting fix

    dmsnell committed Apr 24, 2023
    Configuration menu
    Copy the full SHA
    367dc00 View commit details
    Browse the repository at this point in the history