From 48e733f2789f1a7a322d41825b296e9818409343 Mon Sep 17 00:00:00 2001 From: ramonjd Date: Thu, 7 Apr 2022 12:29:14 +1000 Subject: [PATCH] Adding whitespace to inline output --- packages/style-engine/class-wp-style-engine.php | 6 +++--- .../style-engine/phpunit/class-wp-style-engine-test.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/style-engine/class-wp-style-engine.php b/packages/style-engine/class-wp-style-engine.php index 766b06ea1df4ac..fe850ba220a875 100644 --- a/packages/style-engine/class-wp-style-engine.php +++ b/packages/style-engine/class-wp-style-engine.php @@ -175,15 +175,15 @@ public function generate( $block_styles, $options = array() ) { // Generate inline style rules. if ( isset( $options['inline'] ) && true === $options['inline'] ) { foreach ( $rules as $rule => $value ) { - $filtered_css = esc_html( safecss_filter_attr( "{$rule}:{$value}" ) ); + $filtered_css = esc_html( safecss_filter_attr( "{$rule}: {$value}" ) ); if ( ! empty( $filtered_css ) ) { - $output .= $filtered_css . ';'; + $output .= $filtered_css . '; '; } } } } - return $output; + return trim( $output ); } /** diff --git a/packages/style-engine/phpunit/class-wp-style-engine-test.php b/packages/style-engine/phpunit/class-wp-style-engine-test.php index a7fe6b0e8ab810..9fd262d49ced73 100644 --- a/packages/style-engine/phpunit/class-wp-style-engine-test.php +++ b/packages/style-engine/phpunit/class-wp-style-engine-test.php @@ -104,7 +104,7 @@ public function data_block_styles_fixtures() { 'path' => array( 'spacing', 'margin' ), 'inline' => true, ), - 'expected_output' => 'margin:111px;', + 'expected_output' => 'margin: 111px;', ), 'inline_valid_single_style' => array( @@ -128,7 +128,7 @@ public function data_block_styles_fixtures() { 'path' => array( 'spacing', 'padding' ), 'inline' => true, ), - 'expected_output' => 'padding-top:42px;padding-left:2%;padding-bottom:44px;padding-right:5rem;', + 'expected_output' => 'padding-top: 42px; padding-left: 2%; padding-bottom: 44px; padding-right: 5rem;', ), 'inline_valid_multiple_spacing_style' => array( @@ -151,7 +151,7 @@ public function data_block_styles_fixtures() { 'options' => array( 'inline' => true, ), - 'expected_output' => 'padding-top:42px;padding-left:2%;padding-bottom:44px;padding-right:5rem;margin-top:12rem;margin-left:2vh;margin-bottom:2px;margin-right:10em;', + 'expected_output' => 'padding-top: 42px; padding-left: 2%; padding-bottom: 44px; padding-right: 5rem; margin-top: 12rem; margin-left: 2vh; margin-bottom: 2px; margin-right: 10em;', ), 'inline_valid_multiple_typography_style' => array( @@ -170,7 +170,7 @@ public function data_block_styles_fixtures() { 'options' => array( 'inline' => true, ), - 'expected_output' => 'font-family:Roboto,Oxygen-Sans,Ubuntu,sans-serif;font-style:italic;font-weight:800;line-height:1.3;text-decoration:underline;text-transform:uppercase;letter-spacing:2;', + 'expected_output' => 'font-family: Roboto,Oxygen-Sans,Ubuntu,sans-serif; font-style: italic; font-weight: 800; line-height: 1.3; text-decoration: underline; text-transform: uppercase; letter-spacing: 2;', ), ); }