@@ -1416,7 +1416,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
1416
1416
$ 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.
1417
1417
$ node = _wp_array_get ( $ this ->theme_json , $ block_metadata ['path ' ], array () );
1418
1418
$ layout_definitions = wp_get_layout_definitions ();
1419
- $ layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/ ' ; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.
1419
+ $ layout_selector_pattern = '/^[a-zA-Z0-9\-\.\,\ *+>:\(\)]*$/ ' ; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.
1420
1420
1421
1421
/*
1422
1422
* Gap styles will only be output if the theme has block gap support, or supports a fallback gap.
@@ -1491,7 +1491,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
1491
1491
$ spacing_rule ['selector ' ]
1492
1492
);
1493
1493
} else {
1494
- $ format = static ::ROOT_BLOCK_SELECTOR === $ selector ? ':where(%s .% s) %s ' : '% s-%s% s ' ;
1494
+ $ format = static ::ROOT_BLOCK_SELECTOR === $ selector ? ':where(.%2$ s) %3$ s ' : ':where(%1$ s-%2$s) %3$ s ' ;
1495
1495
$ layout_selector = sprintf (
1496
1496
$ format ,
1497
1497
$ selector ,
@@ -1575,7 +1575,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) {
1575
1575
}
1576
1576
1577
1577
$ layout_selector = sprintf (
1578
- '%s .%s%s ' ,
1578
+ '.%s%s ' ,
1579
1579
$ selector ,
1580
1580
$ class_name ,
1581
1581
$ base_style_rule ['selector ' ]
@@ -2582,7 +2582,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
2582
2582
}
2583
2583
2584
2584
// 2. Generate and append the rules that use the general selector.
2585
- $ block_rules .= static ::to_ruleset ( $ selector , $ declarations );
2585
+ $ block_rules .= static ::to_ruleset ( " :where( $ selector) " , $ declarations );
2586
2586
2587
2587
// 3. Generate and append the rules that use the duotone selector.
2588
2588
if ( isset ( $ block_metadata ['duotone ' ] ) && ! empty ( $ declarations_duotone ) ) {
@@ -2599,7 +2599,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
2599
2599
2600
2600
// 5. Generate and append the feature level rulesets.
2601
2601
foreach ( $ feature_declarations as $ feature_selector => $ individual_feature_declarations ) {
2602
- $ block_rules .= static ::to_ruleset ( $ feature_selector , $ individual_feature_declarations );
2602
+ $ block_rules .= static ::to_ruleset ( " :where( $ feature_selector) " , $ individual_feature_declarations );
2603
2603
}
2604
2604
2605
2605
// 6. Generate and append the style variation rulesets.
@@ -2632,7 +2632,7 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
2632
2632
* user-generated values take precedence in the CSS cascade.
2633
2633
* @link https://github.com/WordPress/gutenberg/issues/36147.
2634
2634
*/
2635
- $ css .= 'body { margin: 0; ' ;
2635
+ $ css .= ':where( body) { margin: 0; ' ;
2636
2636
2637
2637
/*
2638
2638
* If there are content and wide widths in theme.json, output them
@@ -2675,8 +2675,8 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
2675
2675
if ( $ has_block_gap_support ) {
2676
2676
$ block_gap_value = static ::get_property_value ( $ this ->theme_json , array ( 'styles ' , 'spacing ' , 'blockGap ' ) );
2677
2677
$ css .= ":where(.wp-site-blocks) > * { margin-block-start: $ block_gap_value; margin-block-end: 0; } " ;
2678
- $ css .= ':where(.wp-site-blocks) > :first-child:first-child { margin-block-start: 0; } ' ;
2679
- $ css .= ':where(.wp-site-blocks) > :last-child:last-child { margin-block-end: 0; } ' ;
2678
+ $ css .= ':where(.wp-site-blocks) > :first-child { margin-block-start: 0; } ' ;
2679
+ $ css .= ':where(.wp-site-blocks) > :last-child { margin-block-end: 0; } ' ;
2680
2680
2681
2681
// For backwards compatibility, ensure the legacy block gap CSS variable is still available.
2682
2682
$ css .= "$ selector { --wp--style--block-gap: $ block_gap_value; } " ;
0 commit comments