Skip to content

Commit

Permalink
Styles: try wrapping with :root to fix reset styles
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored and aaronrobertshaw committed May 17, 2024
1 parent 861437c commit e7d1c53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@ static function ( $pseudo_selector ) use ( $selector ) {
}

// 2. Generate and append the rules that use the general selector.
$block_rules .= static::to_ruleset( ":where($selector)", $declarations );
$block_rules .= static::to_ruleset( ":root :where($selector)", $declarations );

// 3. Generate and append the rules that use the duotone selector.
if ( isset( $block_metadata['duotone'] ) && ! empty( $declarations_duotone ) ) {
Expand All @@ -2762,7 +2762,7 @@ static function ( $pseudo_selector ) use ( $selector ) {

// 5. Generate and append the feature level rulesets.
foreach ( $feature_declarations as $feature_selector => $individual_feature_declarations ) {
$block_rules .= static::to_ruleset( ":where($feature_selector)", $individual_feature_declarations );
$block_rules .= static::to_ruleset( ":root :where($feature_selector)", $individual_feature_declarations );
}

// 6. Generate and append the style variation rulesets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ export const toStyles = (
( [ cssSelector, declarations ] ) => {
if ( declarations.length ) {
const rules = declarations.join( ';' );
ruleset += `:where(${ cssSelector }){${ rules };}`;
ruleset += `:root :where(${ cssSelector }){${ rules };}`;
}
}
);
Expand Down Expand Up @@ -956,7 +956,7 @@ export const toStyles = (
isTemplate
);
if ( declarations?.length ) {
ruleset += `:where(${ selector }){${ declarations.join(
ruleset += `:root :where(${ selector }){${ declarations.join(
';'
) };}`;
}
Expand Down

0 comments on commit e7d1c53

Please sign in to comment.