[wp-trac] [WordPress Trac] #62290: Unable to seek to any bookmark in HTML Processor
WordPress Trac
noreply at wordpress.org
Thu Oct 24 00:37:56 UTC 2024
#62290: Unable to seek to any bookmark in HTML Processor
--------------------------+-----------------------------
Reporter: westonruter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTML API | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Given this test case:
{{{#!php
<?php
$bookmark_name = 'the-bookmark';
$html = <<<HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>...</title>
</head>
<body>
<div id="$bookmark_name"></div>
</body>
</html>
HTML;
$processor = WP_HTML_Processor::create_full_parser( $html );
while ( $processor->next_tag() ) {
if ( 'DIV' === $processor->get_tag() && !
$processor->set_bookmark( $bookmark_name ) ) {
throw new Exception( "Failed to set bookmark" );
}
}
if ( ! $processor->has_bookmark( $bookmark_name ) ) {
throw new Exception( "Unexpectedly has_bookmark returned false."
);
}
if ( ! $processor->seek( $bookmark_name ) ) {
throw new Exception( "Failed to seek to bookmark." );
}
}}}
The call to `seek` unexpectedly returns `false`, even though the bookmark
was set and `has_bookmark()` returned `true`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62290>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list