Make WordPress Core

Changeset 54774


Ignore:
Timestamp:
11/09/2022 04:06:47 AM (19 months ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r54501 r54774  
    395395     * Defines which pseudo selectors are enabled for which elements.
    396396     *
     397     * The order of the selectors should be: visited, hover, focus, active.
     398     * This is to ensure that 'visited' has the lowest specificity
     399     * and the other selectors can always overwrite it.
     400     *
     401     * See https://core.trac.wordpress.org/ticket/56928.
    397402     * Note: this will affect both top-level and block-level elements.
    398403     *
     
    400405     */
    401406    const VALID_ELEMENT_PSEUDO_SELECTORS = array(
    402         'link'   => array( ':hover', ':focus', ':active', ':visited' ),
    403         'button' => array( ':hover', ':focus', ':active', ':visited' ),
     407        'link'   => array( ':visited', ':hover', ':focus', ':active' ),
     408        'button' => array( ':visited', ':hover', ':focus', ':active' ),
    404409    );
    405410
Note: See TracChangeset for help on using the changeset viewer.