Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #63020


Ignore:
Timestamp:
02/26/2025 07:39:34 PM (13 months ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #63020

    • Property Milestone changed from Future Release to 6.9
  • Ticket #63020 – Description

    initial v2  
    88
    99All this to say, `WP_HTML_Processor` does not keep track of element node indices, and it doesn't expose the attributes for the tags in the open stack (e.g. to get the `id`, `role`, or `class`). This would seem to make it more difficult to implement `get_xpath()` than maybe it should be. Ideally computing the XPath wouldn't require subclassing at all, and the information could be obtained from existing public methods. In Optimization Detective, the `WP_HTML_Tag_Processor` class is extended and the `next_token()` method is overridden so it can construct its own breadcrumbs and then also compute the node indices and capture the attributes at a given depth.
     10
     11All this to say, I suggest that in addition to `get_breadcrumbs()` that there be a way to get more information from the open stack of tags, including the attributes for each tag and the node index for each.