@@ -437,14 +437,16 @@ public function spawn_fragment_parser( string $html ): ?self {
437437 return null ;
438438 }
439439
440+ $ namespace = $ this ->get_namespace ();
441+
440442 /*
441443 * Prevent creating fragments at "self-contained" nodes.
442444 *
443445 * @see https://github.com/WordPress/wordpress-develop/pull/7141
444446 * @see https://github.com/WordPress/wordpress-develop/pull/7198
445447 */
446448 if (
447- 'html ' === $ this -> get_namespace () &&
449+ 'html ' === $ namespace &&
448450 in_array ( $ this ->get_tag (), array ( 'IFRAME ' , 'NOEMBED ' , 'NOFRAMES ' , 'SCRIPT ' , 'STYLE ' , 'TEXTAREA ' , 'TITLE ' , 'XMP ' ), true )
449451 ) {
450452 return null ;
@@ -453,19 +455,17 @@ public function spawn_fragment_parser( string $html ): ?self {
453455 $ fragment_processor = self ::create_fragment ( $ html );
454456 $ fragment_processor ->compat_mode = $ this ->compat_mode ;
455457
456- $ context_element = array ( $ this ->get_tag (), array () );
458+
459+ $ fragment_processor ->context_node = clone $ this ->state ->current_token ;
460+ $ fragment_processor ->context_node ->bookmark_name = 'context-node ' ;
461+ $ fragment_processor ->context_node ->on_destroy = null ;
462+
463+ $ context_element = array ( $ fragment_processor ->context_node ->node_name , array () );
457464 foreach ( $ this ->get_attribute_names_with_prefix ( '' ) as $ name => $ value ) {
458465 $ context_element [1 ][ $ name ] = $ value ;
459466 }
460467
461- $ fragment_processor ->context_node = new WP_HTML_Token (
462- 'context-node ' ,
463- $ context_element [0 ],
464- $ this ->has_self_closing_flag ()
465- );
466- $ fragment_processor ->context_node ->namespace = $ this ->get_namespace ();
467-
468- $ fragment_processor ->state ->context_node = $ context_element ;
468+ $ fragment_processor ->breadcrumbs = array ();
469469
470470 if ( 'TEMPLATE ' === $ context_element [0 ] ) {
471471 $ fragment_processor ->state ->stack_of_template_insertion_modes [] = WP_HTML_Processor_State::INSERTION_MODE_IN_TEMPLATE ;
0 commit comments