Skip to content

Commit

Permalink
Don't call append_to_selector() when selector is likely empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed May 2, 2023
1 parent 7e8cc35 commit 45473d9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1556,10 +1556,13 @@ protected static function compute_preset_classes( $settings, $selector, $origins
$slugs = static::get_settings_slugs( $settings, $preset_metadata, $origins );
foreach ( $preset_metadata['classes'] as $class => $property ) {
foreach ( $slugs as $slug ) {
$css_var = static::replace_slug_in_string( $preset_metadata['css_vars'], $slug );
$class_name = static::replace_slug_in_string( $class, $slug );
$stylesheet .= static::to_ruleset(
static::append_to_selector( $selector, $class_name ),
$css_var = static::replace_slug_in_string( $preset_metadata['css_vars'], $slug );
$class_name = static::replace_slug_in_string( $class, $slug );

// $selector is often empty, so we can save ourselves the `append_to_selector()` call then.
$new_selector = '' === $selector ? $class_name : static::append_to_selector( $selector, $class_name );
$stylesheet .= static::to_ruleset(
$new_selector,
array(
array(
'name' => $property,
Expand Down

0 comments on commit 45473d9

Please sign in to comment.