From cbbb439637a24cd39228d09f6af7e6b932da54f4 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 21 Nov 2024 20:05:42 +0100 Subject: [PATCH 1/2] Remove unused processor state context_node property --- .../html-api/class-wp-html-processor-state.php | 11 ----------- src/wp-includes/html-api/class-wp-html-processor.php | 12 +----------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor-state.php b/src/wp-includes/html-api/class-wp-html-processor-state.php index b7cdd347ca85b..a9123bd8e8d6f 100644 --- a/src/wp-includes/html-api/class-wp-html-processor-state.php +++ b/src/wp-includes/html-api/class-wp-html-processor-state.php @@ -356,17 +356,6 @@ class WP_HTML_Processor_State { */ public $insertion_mode = self::INSERTION_MODE_INITIAL; - /** - * Context node initializing fragment parser, if created as a fragment parser. - * - * @since 6.4.0 - * - * @see https://html.spec.whatwg.org/#concept-frag-parse-context - * - * @var [string, array]|null - */ - public $context_node = null; - /** * The recognized encoding of the input byte stream. * 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 39196499fa5af..e7b97709ab9eb 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -298,7 +298,6 @@ public static function create_fragment( $html, $context = '', $encoding = } $processor = new static( $html, self::CONSTRUCTOR_UNLOCK_CODE ); - $processor->state->context_node = array( 'BODY', array() ); $processor->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_BODY; $processor->state->encoding = $encoding; $processor->state->encoding_confidence = 'certain'; @@ -317,7 +316,7 @@ public static function create_fragment( $html, $context = '', $encoding = $context_node = new WP_HTML_Token( 'context-node', - $processor->state->context_node[0], + 'BODY', false ); @@ -492,15 +491,6 @@ public function create_fragment_at_current_node( string $html ) { $fragment_processor->context_node->bookmark_name = 'context-node'; $fragment_processor->context_node->on_destroy = null; - $fragment_processor->state->context_node = array( $fragment_processor->context_node->node_name, array() ); - - $attribute_names = $this->get_attribute_names_with_prefix( '' ); - if ( null !== $attribute_names ) { - foreach ( $attribute_names as $name ) { - $fragment_processor->state->context_node[1][ $name ] = $this->get_attribute( $name ); - } - } - $fragment_processor->breadcrumbs = array( 'HTML', $fragment_processor->context_node->node_name ); if ( 'TEMPLATE' === $fragment_processor->context_node->node_name ) { From e2ae44a5a27552d12cf78bfa15d480e87cb10ba6 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 26 Nov 2024 17:42:18 +0100 Subject: [PATCH 2/2] Restore and deprecate the context_node property --- .../html-api/class-wp-html-processor-state.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wp-includes/html-api/class-wp-html-processor-state.php b/src/wp-includes/html-api/class-wp-html-processor-state.php index a9123bd8e8d6f..b257aa809da75 100644 --- a/src/wp-includes/html-api/class-wp-html-processor-state.php +++ b/src/wp-includes/html-api/class-wp-html-processor-state.php @@ -356,6 +356,16 @@ class WP_HTML_Processor_State { */ public $insertion_mode = self::INSERTION_MODE_INITIAL; + /** + * Context node initializing fragment parser, if created as a fragment parser. + * + * @since 6.4.0 + * @deprecated 6.8.0 WP_HTML_Processor tracks the context_node internally. + * + * @var null + */ + public $context_node = null; + /** * The recognized encoding of the input byte stream. *