[wp-trac] [WordPress Trac] #62270: Unable to set bookmark on </body> in WP_HTML_Processor
WordPress Trac
noreply at wordpress.org
Mon Oct 21 23:36:18 UTC 2024
#62270: Unable to set bookmark on </body> in WP_HTML_Processor
--------------------------+-----------------------------
Reporter: westonruter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTML API | Version: 6.4
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In the Optimization Detective plugin from the WordPress Core Performance
Team, the HTML Tag Processor is currently used to locate the closing
`</body>` tag,
[https://github.com/WordPress/performance/blob/e95df5fda18a55c7d11c34a23120301272b3b383/plugins
/optimization-detective/class-od-html-tag-processor.php#L344-L345 set a
bookmark] on it, and then
[https://github.com/WordPress/performance/blob/e95df5fda18a55c7d11c34a23120301272b3b383/plugins
/optimization-detective/class-od-html-tag-processor.php#L593-L618 inject]
[https://github.com/WordPress/performance/blob/e95df5fda18a55c7d11c34a23120301272b3b383/plugins
/optimization-detective/class-od-html-tag-processor.php#L567-L569 pending
markup] at that point when `get_updated_html()` is called after the
document has been iterated over.
This works well with `WP_HTML_Tag_Processor`, but it does not work with
`WP_HTML_Processor` because when the processor is located at `</body>` the
parser state gets set to `STATE_COMPLETE` and then `set_bookmark()` short-
circuits returning `false`. It doesn't seem that `STATE_COMPLETE` should
be reached until the end of the document is reached.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62270>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list