@@ -1424,7 +1424,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
1424
1424
$ has_fallback_gap_support = ! $ has_block_gap_support ; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback gap styles support.
1425
1425
$ node = _wp_array_get ( $ this ->theme_json , $ block_metadata ['path ' ], array () );
1426
1426
$ layout_definitions = wp_get_layout_definitions ();
1427
- $ layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/ ' ; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.
1427
+ $ layout_selector_pattern = '/^[a-zA-Z0-9\-\.\,\ *+>:\(\)]*$/ ' ; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.
1428
1428
1429
1429
/*
1430
1430
* Gap styles will only be output if the theme has block gap support, or supports a fallback gap.
@@ -1499,7 +1499,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
1499
1499
$ spacing_rule ['selector ' ]
1500
1500
);
1501
1501
} else {
1502
- $ format = static ::ROOT_BLOCK_SELECTOR === $ selector ? ':where(%s .% s) %s ' : '% s-%s% s ' ;
1502
+ $ format = static ::ROOT_BLOCK_SELECTOR === $ selector ? ':where(.%2$ s) %3$ s ' : ':where(%1$ s-%2$s) %3$ s ' ;
1503
1503
$ layout_selector = sprintf (
1504
1504
$ format ,
1505
1505
$ selector ,
@@ -1583,7 +1583,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
1583
1583
}
1584
1584
1585
1585
$ layout_selector = sprintf (
1586
- '%s .%s%s ' ,
1586
+ '.%s%s ' ,
1587
1587
$ selector ,
1588
1588
$ class_name ,
1589
1589
$ base_style_rule ['selector ' ]
@@ -2591,7 +2591,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
2591
2591
}
2592
2592
2593
2593
// 2. Generate and append the rules that use the general selector.
2594
- $ block_rules .= static ::to_ruleset ( $ selector , $ declarations );
2594
+ $ block_rules .= static ::to_ruleset ( " :where( $ selector) " , $ declarations );
2595
2595
2596
2596
// 3. Generate and append the rules that use the duotone selector.
2597
2597
if ( isset ( $ block_metadata ['duotone ' ] ) && ! empty ( $ declarations_duotone ) ) {
@@ -2608,7 +2608,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
2608
2608
2609
2609
// 5. Generate and append the feature level rulesets.
2610
2610
foreach ( $ feature_declarations as $ feature_selector => $ individual_feature_declarations ) {
2611
- $ block_rules .= static ::to_ruleset ( $ feature_selector , $ individual_feature_declarations );
2611
+ $ block_rules .= static ::to_ruleset ( " :where( $ feature_selector) " , $ individual_feature_declarations );
2612
2612
}
2613
2613
2614
2614
// 6. Generate and append the style variation rulesets.
@@ -2643,8 +2643,8 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
2643
2643
$ content_size = static ::is_safe_css_declaration ( 'max-width ' , $ content_size ) ? $ content_size : 'initial ' ;
2644
2644
$ wide_size = isset ( $ settings ['layout ' ]['wideSize ' ] ) ? $ settings ['layout ' ]['wideSize ' ] : $ settings ['layout ' ]['contentSize ' ];
2645
2645
$ wide_size = static ::is_safe_css_declaration ( 'max-width ' , $ wide_size ) ? $ wide_size : 'initial ' ;
2646
- $ css .= static ::ROOT_CSS_PROPERTIES_SELECTOR . ' { --wp--style--global--content-size: ' . $ content_size . '; ' ;
2647
- $ css .= '--wp--style--global--wide-size: ' . $ wide_size . '; } ' ;
2646
+ $ css .= static ::ROOT_CSS_PROPERTIES_SELECTOR . ' { --wp--style--global--content-size: ' . $ content_size . '; ' ;
2647
+ $ css .= '--wp--style--global--wide-size: ' . $ wide_size . '; } ' ;
2648
2648
}
2649
2649
2650
2650
/*
@@ -2655,7 +2655,7 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
2655
2655
* user-generated values take precedence in the CSS cascade.
2656
2656
* @link https://github.com/WordPress/gutenberg/issues/36147.
2657
2657
*/
2658
- $ css .= 'body { margin: 0; } ' ;
2658
+ $ css .= ':where( body) { margin: 0; } ' ;
2659
2659
2660
2660
if ( $ use_root_padding ) {
2661
2661
// Top and bottom padding are applied to the outer block container.
@@ -2682,8 +2682,8 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
2682
2682
if ( isset ( $ this ->theme_json ['settings ' ]['spacing ' ]['blockGap ' ] ) ) {
2683
2683
$ block_gap_value = static ::get_property_value ( $ this ->theme_json , array ( 'styles ' , 'spacing ' , 'blockGap ' ) );
2684
2684
$ css .= ":where(.wp-site-blocks) > * { margin-block-start: $ block_gap_value; margin-block-end: 0; } " ;
2685
- $ css .= ':where(.wp-site-blocks) > :first-child:first-child { margin-block-start: 0; } ' ;
2686
- $ css .= ':where(.wp-site-blocks) > :last-child:last-child { margin-block-end: 0; } ' ;
2685
+ $ css .= ':where(.wp-site-blocks) > :first-child { margin-block-start: 0; } ' ;
2686
+ $ css .= ':where(.wp-site-blocks) > :last-child { margin-block-end: 0; } ' ;
2687
2687
2688
2688
// For backwards compatibility, ensure the legacy block gap CSS variable is still available.
2689
2689
$ css .= static ::ROOT_CSS_PROPERTIES_SELECTOR . " { --wp--style--block-gap: $ block_gap_value; } " ;
0 commit comments