Make WordPress Core


Ignore:
Timestamp:
08/09/2024 03:38:13 PM (2 years ago)
Author:
hellofromTonya
Message:

Theme JSON: Ensure root selector (body) is not wrapped in :root :where().

Pre-WordPress 6.6, the body selector was used for styles associated with the body.

In 6.6, this was mistakenly changed to :root :where(body), an increase in specificity, causing some issues for themes.

This change reverts the specificity increase, styles again use the body selector.

Syncs PHP changes from https://github.com/WordPress/gutenberg/pull/63726.

Reviewed by hellofromTonya.
Merges [58856] and [58861] to the 6.6 branch.

Props talldanwp, andrewserong, aaronrobertshaw, mukesh27, hellofromTonya.
Fixes #61704.

Location:
branches/6.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.6

  • branches/6.6/src/wp-includes/class-wp-theme-json.php

    r58751 r58874  
    28812881
    28822882                /*
     2883                 * Root selector (body) styles should not be wrapped in `:root where()` to keep
     2884                 * specificity at (0,0,1) and maintain backwards compatibility.
     2885                 *
    28832886                 * Top-level element styles using element-only specificity selectors should
    28842887                 * not get wrapped in `:root :where()` to maintain backwards compatibility.
     
    28882891                 * variations etc. Pseudo selectors won't match the ELEMENTS selector exactly.
    28892892                 */
    2890                 $element_only_selector = $current_element &&
     2893                $element_only_selector = $is_root_selector || (
     2894                        $current_element &&
    28912895                        isset( static::ELEMENTS[ $current_element ] ) &&
    28922896                        // buttons, captions etc. still need `:root :where()` as they are class based selectors.
    28932897                        ! isset( static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES[ $current_element ] ) &&
    2894                         static::ELEMENTS[ $current_element ] === $selector;
     2898                        static::ELEMENTS[ $current_element ] === $selector
     2899                );
    28952900
    28962901                // 2. Generate and append the rules that use the general selector.
Note: See TracChangeset for help on using the changeset viewer.