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.

Built from https://develop.svn.wordpress.org/trunk@54774


git-svn-id: http://core.svn.wordpress.org/trunk@54326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-11-09 04:08:16 +00:00
parent 113838ed78
commit 63f944e831
2 changed files with 8 additions and 3 deletions

View File

@ -394,13 +394,18 @@ class WP_Theme_JSON {
/** /**
* Defines which pseudo selectors are enabled for which elements. * 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. * Note: this will affect both top-level and block-level elements.
* *
* @since 6.1.0 * @since 6.1.0
*/ */
const VALID_ELEMENT_PSEUDO_SELECTORS = array( const VALID_ELEMENT_PSEUDO_SELECTORS = array(
'link' => array( ':hover', ':focus', ':active', ':visited' ), 'link' => array( ':visited', ':hover', ':focus', ':active' ),
'button' => array( ':hover', ':focus', ':active', ':visited' ), 'button' => array( ':visited', ':hover', ':focus', ':active' ),
); );
/** /**

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-alpha-54771'; $wp_version = '6.2-alpha-54774';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.