From bbf1a34454d468ad4b9f0143741ec505c78d0cd6 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Wed, 9 Nov 2022 04:06:47 +0000 Subject: [PATCH] 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 --- src/wp-includes/class-wp-theme-json.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 555898370f..d0fcdeb52a 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -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' ), ); /**