Skip to content

Commit b0439d4

Browse files
committed
WIP
1 parent dfe44d1 commit b0439d4

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/wp-includes/script-loader.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,16 +3450,35 @@ function wp_enqueue_command_palette_assets() {
34503450
return '';
34513451
}
34523452

3453-
$processor = WP_HTML_Processor::create_fragment( $label );
3453+
$processor = new WP_HTML_Tag_Processor( $label );
34543454
$text_parts = array();
3455+
$depth = 0;
34553456

3456-
if ( $processor->next_token() ) {
3457-
$root_depth = $processor->get_current_depth();
3458-
do {
3459-
if ( '#text' === $processor->get_token_type() && $root_depth === $processor->get_current_depth() ) {
3457+
while ( $processor->next_token() ) {
3458+
$token_type = $processor->get_token_type();
3459+
3460+
if ( '#text' === $token_type ) {
3461+
if ( 0 === $depth ) {
34603462
$text_parts[] = $processor->get_modifiable_text();
34613463
}
3462-
} while ( $processor->next_token() );
3464+
continue;
3465+
}
3466+
3467+
if ( '#tag' !== $token_type ) {
3468+
continue;
3469+
}
3470+
3471+
if ( $processor->is_tag_closer() ) {
3472+
if ( $depth > 0 ) {
3473+
$depth--;
3474+
}
3475+
continue;
3476+
}
3477+
3478+
$token_name = $processor->get_tag();
3479+
if ( $token_name && ! WP_HTML_Processor::is_void( $token_name ) ) {
3480+
$depth++;
3481+
}
34633482
}
34643483

34653484
return trim( implode( '', $text_parts ) );

0 commit comments

Comments
 (0)