From 9a0c01798fd6e34676b7d090563c7868bdb24a11 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 6 Nov 2024 12:05:43 +0100 Subject: [PATCH] Set parsing namespace correctly when seeking --- src/wp-includes/html-api/class-wp-html-processor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 62a67ffc86e97..2482dc53d3d47 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -5347,7 +5347,6 @@ public function seek( $bookmark_name ): bool { * This must be done after clearing the stack because those stacks generate events that * would appear on a subsequent call to `next_token()`. */ - $this->change_parsing_namespace( 'html' ); $this->state->frameset_ok = true; $this->state->stack_of_template_insertion_modes = array(); $this->state->head_element = null; @@ -5358,6 +5357,7 @@ public function seek( $bookmark_name ): bool { // The presence or absence of a context node indicates a full or fragment parser. if ( null === $this->context_node ) { + $this->change_parsing_namespace( 'html' ); $this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_INITIAL; $this->breadcrumbs = array(); @@ -5365,6 +5365,11 @@ public function seek( $bookmark_name ): bool { $this->parser_state = self::STATE_READY; $this->next_token(); } else { + $this->change_parsing_namespace( + $this->context_node->integration_node_type + ? 'html' + : $this->context_node->namespace + ); $this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_BODY; $this->breadcrumbs = array_slice( $this->breadcrumbs, 0, 2 ); parent::seek( $this->context_node->bookmark_name );