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: Report breadcrumbs properly when paused on virtual nodes. #6914

Closed

Conversation

dmsnell
Copy link
Contributor

@dmsnell dmsnell commented Jun 26, 2024

Follow-up to [58304]
See Core-61348

Status

  • Needs merge to trunk
  • Needs backport into 6.6 RC

Summary

Previously the breadcrumbs were only generated for real nodes, and when visiting virtual nodes, the parser had already traversed past them to the next real node, advancing the breadcrumbs ahead of the matched token.

Test in the Playground

Screenshot 2024-06-26 at 5 17 25 PM

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@sirreal
Copy link
Member

sirreal commented Jun 27, 2024

This seems to fix breadcrumbs, but get_current_depth may report the wrong depth in some cases that are fixes for breadcrumbs with this change.

@dmsnell
Copy link
Contributor Author

dmsnell commented Jun 27, 2024

get_current_depth may report the wrong depth in some cases that are fixes for breadcrumbs with this change.

good point. in my head it was using breadcrumbs() already, but now it actually is with 21bc01b

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

This fixes some breadcrumbs and depth issues in my testing 👍

@dmsnell dmsnell marked this pull request as ready for review June 27, 2024 19:39
Copy link

github-actions bot commented Jun 27, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dmsnell, jonsurrell, zieladam.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

pento pushed a commit that referenced this pull request Jun 27, 2024
When [58304] introduced the abililty to visit virtual nodes in the HTML document,
those being the nodes which are implied by the HTML but no explicitly present in
the raw text, a bug was introduced in the `get_breadcrumbs()` method because it
wasn't updated to be aware of the virtual nodes. Therefore it would report the
wrong breadcrumbs for virtual nodes. Since the new `get_depth()` method is based
on the same logic it was also broken for virtual nodes.

In this patch, the breadcrumbs have been updated to account for the virtual nodes
and the depth method has been updated to rely on the fixed breadcrumb logic.

Developed in #6914
Discussed in https://core.trac.wordpress.org/ticket/61348

Follow-up to [58304].

Props dmsnell, jonsurrell, zieladam.
See #61348.


git-svn-id: https://develop.svn.wordpress.org/trunk@58588 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jun 27, 2024
When [58304] introduced the abililty to visit virtual nodes in the HTML document,
those being the nodes which are implied by the HTML but no explicitly present in
the raw text, a bug was introduced in the `get_breadcrumbs()` method because it
wasn't updated to be aware of the virtual nodes. Therefore it would report the
wrong breadcrumbs for virtual nodes. Since the new `get_depth()` method is based
on the same logic it was also broken for virtual nodes.

In this patch, the breadcrumbs have been updated to account for the virtual nodes
and the depth method has been updated to rely on the fixed breadcrumb logic.

Developed in WordPress/wordpress-develop#6914
Discussed in https://core.trac.wordpress.org/ticket/61348

Follow-up to [58304].

Props dmsnell, jonsurrell, zieladam.
See #61348.

Built from https://develop.svn.wordpress.org/trunk@58588


git-svn-id: http://core.svn.wordpress.org/trunk@58035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@dmsnell
Copy link
Contributor Author

dmsnell commented Jun 27, 2024

Merged in [58588]
9cbaee3

@dmsnell dmsnell closed this Jun 27, 2024
@dmsnell dmsnell deleted the html-api/fix-virtual-breadcrumbs branch June 27, 2024 20:54
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Jun 27, 2024
When [58304] introduced the abililty to visit virtual nodes in the HTML document,
those being the nodes which are implied by the HTML but no explicitly present in
the raw text, a bug was introduced in the `get_breadcrumbs()` method because it
wasn't updated to be aware of the virtual nodes. Therefore it would report the
wrong breadcrumbs for virtual nodes. Since the new `get_depth()` method is based
on the same logic it was also broken for virtual nodes.

In this patch, the breadcrumbs have been updated to account for the virtual nodes
and the depth method has been updated to rely on the fixed breadcrumb logic.

Developed in WordPress/wordpress-develop#6914
Discussed in https://core.trac.wordpress.org/ticket/61348

Follow-up to [58304].

Props dmsnell, jonsurrell, zieladam.
See #61348.

Built from https://develop.svn.wordpress.org/trunk@58588


git-svn-id: https://core.svn.wordpress.org/trunk@58035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@gziolo
Copy link
Member

gziolo commented Jun 28, 2024

get_current_depth may report the wrong depth in some cases that are fixes for breadcrumbs with this change.

good point. in my head it was using breadcrumbs() already, but now it actually is with 21bc01b

What is the minimal test cases that would cover this issue? We are in the RC phase, so better to stay on the safe side. When testing with the Playground link provided everything works as expected.

@sirreal
Copy link
Member

sirreal commented Jun 28, 2024

</p> is a good test case for this. I'll add some unit tests in another PR.

You can see that the P tags are created at the wrong depth with the wrong breadcrumbs here (hover them for a tooltip and notice their nesting)

In this PR that's been fixed.

@gziolo
Copy link
Member

gziolo commented Jun 28, 2024

To close the loop here, I backported changes with https://core.trac.wordpress.org/changeset/58590 to the 6.6 release branch.

@sirreal
Copy link
Member

sirreal commented Jun 28, 2024

It would be great to land #6929 as a follow-up to this with unit tests.

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