Themes: Re-order valid link pseudo classes.

Re-order the link pseudo classes to follow the long term LoVe (F)HA rule when set via `theme.json`.

In order that the CSS cascade behaves in a predictable manner, it's recommended that the selectors follow the order `:visited`, `:focus`/`:hover`, `:active`. As order affects the specificity, this ensures the interaction states override the visited states. CSS specificity is really quite beautiful, although complex.

Props mikachan, sabernhardt, davidbaumwald, mukesh27, Mamaduka, desrosj.
Fixes #56928.


git-svn-id: https://develop.svn.wordpress.org/trunk@54774 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2022-11-09 04:06:47 +00:00
parent 4edede48eb
commit bbf1a34454

View File

@ -394,13 +394,18 @@ class WP_Theme_JSON {
/**
* Defines which pseudo selectors are enabled for which elements.
*
* The order of the selectors should be: visited, hover, focus, active.
* This is to ensure that 'visited' has the lowest specificity
* and the other selectors can always overwrite it.
*
* See https://core.trac.wordpress.org/ticket/56928.
* Note: this will affect both top-level and block-level elements.
*
* @since 6.1.0
*/
const VALID_ELEMENT_PSEUDO_SELECTORS = array(
'link' => array( ':hover', ':focus', ':active', ':visited' ),
'button' => array( ':hover', ':focus', ':active', ':visited' ),
'link' => array( ':visited', ':hover', ':focus', ':active' ),
'button' => array( ':visited', ':hover', ':focus', ':active' ),
);
/**