Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style Engine: add condition to check for semicolons before adding them to CSS rules #41028

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ public function generate( $block_styles ) {
foreach ( $css_rules as $rule => $value ) {
$filtered_css = esc_html( safecss_filter_attr( "{$rule}: {$value}" ) );
if ( ! empty( $filtered_css ) ) {
$css_output .= $filtered_css . '; ';
$css_output_suffix = str_ends_with( $filtered_css, ';' ) ? ' ' : '; ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together @chad1008 🙇

I'm not convinced this change is required on core.

Block supports, even before the style engine, has been adding ; to inline styles.

See this line here: 6de1698#diff-d61feaa89a4d6e58f54a8f07a04644ea493ef9e203f41a284236abe28a1bd899R86

Furthermore, in between moving from creating inlines styles in block supports files and creating them here in the style engine, the core tests weren't modified and continued to pass.

🤔

It's a curious one though. I would love to know if this is reproducible on WordPress Core (with no plugins/CSS processing).

So far I cannot reproduce it.

$css_output .= $filtered_css . $css_output_suffix;
}
}
}
Expand Down