diff --git a/lib/experimental/html/class-wp-html-tag-processor.php b/lib/experimental/html/class-wp-html-tag-processor.php
index d56556c98f2e71..2c12ce6ac2ea5a 100644
--- a/lib/experimental/html/class-wp-html-tag-processor.php
+++ b/lib/experimental/html/class-wp-html-tag-processor.php
@@ -1447,12 +1447,13 @@ function get_attribute_names_with_prefix( $prefix ) {
$comparable = strtolower( $prefix );
$matches = array_filter(
- array_keys( $this->attributes ),
+ $this->attributes,
function( $attr ) use ( $comparable ) {
return str_starts_with( $attr, $comparable );
- }
+ },
+ ARRAY_FILTER_USE_KEY
);
- return array_values( $matches );
+ return array_keys( $matches );
}
/**