diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php
index dd8e8d5f2d..51b6a5679e 100644
--- a/wp-includes/html-api/class-wp-html-processor.php
+++ b/wp-includes/html-api/class-wp-html-processor.php
@@ -1237,6 +1237,9 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* @return bool Whether the internal cursor was successfully moved to the bookmark's location.
*/
public function seek( $bookmark_name ) {
+ // Flush any pending updates to the document before beginning.
+ $this->get_updated_html();
+
$actual_bookmark_name = "_{$bookmark_name}";
$processor_started_at = $this->state->current_token
? $this->bookmarks[ $this->state->current_token->bookmark_name ]->start
@@ -1246,7 +1249,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
switch ( $direction ) {
case 'forward':
- // When moving forwards, re-parse the document until reaching the same location as the original bookmark.
+ // When moving forwards, reparse the document until reaching the same location as the original bookmark.
while ( $this->step() ) {
if ( $bookmark_starts_at === $this->bookmarks[ $this->state->current_token->bookmark_name ]->start ) {
return true;
@@ -1368,6 +1371,18 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
return parent::set_bookmark( "_{$bookmark_name}" );
}
+ /**
+ * Checks whether a bookmark with the given name exists.
+ *
+ * @since 6.5.0
+ *
+ * @param string $bookmark_name Name to identify a bookmark that potentially exists.
+ * @return bool Whether that bookmark exists.
+ */
+ public function has_bookmark( $bookmark_name ) {
+ return parent::has_bookmark( "_{$bookmark_name}" );
+ }
+
/*
* HTML Parsing Algorithms
*/
diff --git a/wp-includes/version.php b/wp-includes/version.php
index b8a484db34..2dbe2e1856 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.5-alpha-57581';
+$wp_version = '6.5-alpha-57582';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.