Changeset 62853
- Timestamp:
- 07/27/2026 04:09:33 AM (2 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-theme-json.php (modified) (3 diffs)
-
tests/phpunit/tests/theme/wpThemeJson.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r62746 r62853 2433 2433 * } 2434 2434 * 2435 * p.has-value-gradient-background {2435 * :where(p).has-value-gradient-background { 2436 2436 * background: value; 2437 2437 * } … … 2614 2614 * @since 5.9.0 Added the `$origins` parameter. 2615 2615 * @since 6.6.0 Added check for root CSS properties selector. 2616 * @since 7.1.0 Wraps block-level preset classes in `:where()` to match root-level specificity. 2616 2617 * 2617 2618 * @param array $settings Settings to process. … … 2640 2641 $class_name = static::replace_slug_in_string( $class, $slug ); 2641 2642 2642 // $selector is often empty, so we can save ourselves the `append_to_selector()` call then. 2643 $new_selector = '' === $selector ? $class_name : static::append_to_selector( $selector, $class_name ); 2643 /* 2644 * $selector is often empty (root-level presets), in which case the 2645 * bare class is used. For block-level presets the block selector is 2646 * wrapped in `:where()` so the class keeps the same 0-1-0 specificity 2647 * as a root-level preset. Without this, block-level palette rules 2648 * (e.g. `p.has-x-color`) out-rank equally-important rules that also 2649 * target the same property at 0-1-0, such as per-instance responsive 2650 * state styles. 2651 */ 2652 $new_selector = '' === $selector ? $class_name : ':where(' . $selector . ')' . $class_name; 2644 2653 $stylesheet .= static::to_ruleset( 2645 2654 $new_selector, -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r62746 r62853 806 806 * @ticket 52991 807 807 * @ticket 54336 808 * @ticket 65724 808 809 */ 809 810 public function test_get_stylesheet_preset_classes_work_with_compounded_selectors() { … … 829 830 830 831 $this->assertSame( 831 ' .wp-block-heading.has-white-color{color: var(--wp--preset--color--white) !important;}.wp-block-heading.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.wp-block-heading.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}',832 ':where(.wp-block-heading).has-white-color{color: var(--wp--preset--color--white) !important;}:where(.wp-block-heading).has-white-background-color{background-color: var(--wp--preset--color--white) !important;}:where(.wp-block-heading).has-white-border-color{border-color: var(--wp--preset--color--white) !important;}', 832 833 $theme_json->get_stylesheet( array( 'presets' ) ) 833 834 ); … … 895 896 * @ticket 60936 896 897 * @ticket 61165 898 * @ticket 65724 897 899 */ 898 900 public function test_get_stylesheet_preset_rules_come_after_block_rules() { … … 927 929 928 930 $styles = ':root :where(.wp-block-group){color: red;}'; 929 $presets = ' .wp-block-group.has-grey-color{color: var(--wp--preset--color--grey) !important;}.wp-block-group.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.wp-block-group.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}';931 $presets = ':where(.wp-block-group).has-grey-color{color: var(--wp--preset--color--grey) !important;}:where(.wp-block-group).has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}:where(.wp-block-group).has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}'; 930 932 $variables = '.wp-block-group{--wp--preset--color--grey: grey;}'; 931 933
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)