Skip to content

Commit

Permalink
Update comment on HTML Processor and test for seeking.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Jan 23, 2024
1 parent 54d644f commit 5065bee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,12 @@ 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.
*
* @access private
*
* @return bool
*/
Expand Down
6 changes: 5 additions & 1 deletion tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<div><p one><div><p><div two><p><div><p><div><p three>' );
$p = WP_HTML_Processor::create_fragment(
<<<'HTML'
<div>text<p one>more stuff<div><![CDATA[this is not real CDATA]]><p><!-- hi --><div two><p><div><p>three comes soon<div><p three>' );
HTML
);

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

0 comments on commit 5065bee

Please sign in to comment.