From 7d9786db00b730c6b7e2319e35fe8675a45eba5f Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 22 Jan 2024 22:20:23 -0700 Subject: [PATCH] Update comment on HTML Processor and test for seeking. --- src/wp-includes/html-api/class-wp-html-processor.php | 9 ++++++++- .../tests/html-api/wpHtmlProcessorBreadcrumbs.php | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 25603d9521a89..5c3463dae237a 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -416,7 +416,14 @@ public function next_tag( $query = null ) { /** * Steps through the HTML document and stop at the next token, if any. * - * Currently only supports stepping through tags. + * Currently only supports stepping through tags; do not use until this + * supports visiting text nodes. This is necessary for now to ensure that + * the Tag Processor doesn't bypass the HTML semantic rules in this class + * when seeking to a bookmark. + * + * @since 6.5.0 Added for internal support; do not use. + * + * @access private * * @return bool */ diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php index b9d567fbebed6..2e78d6a36bbef 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php @@ -515,7 +515,11 @@ public function test_can_query_an_element_by_tag_name() { * @covers WP_HTML_Processor::seek */ public function test_can_seek_back_and_forth() { - $p = WP_HTML_Processor::create_fragment( '

' ); + $p = WP_HTML_Processor::create_fragment( + <<<'HTML' +

text

more stuff

three comes soon

' ); +HTML + ); // Find first tag of interest. while ( $p->next_tag() && null === $p->get_attribute( 'one' ) ) {