Themes: A11y: Merge omitted changes to support focus-visible.

Merge PHP changes to ensure that `focus` doesn't match `focus-visible` in `WP_Theme_JSON`, overlooked in previous merge. Follow up to [59854].

Props huubl, joemcgill, joedolson.
Fixes #62906.

git-svn-id: https://develop.svn.wordpress.org/trunk@60055 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson 2025-03-19 18:44:41 +00:00
parent bd6741447b
commit dce8fe474d

View File

@ -2906,7 +2906,11 @@ class WP_Theme_JSON {
array_filter(
$element_pseudo_allowed,
static function ( $pseudo_selector ) use ( $selector ) {
return str_contains( $selector, $pseudo_selector );
/*
* Check if the pseudo selector is in the current selector,
* ensuring it is not followed by a dash (e.g., :focus should not match :focus-visible).
*/
return preg_match( '/' . preg_quote( $pseudo_selector, '/' ) . '(?!-)/', $selector ) === 1;
}
)
);