diff --git a/src/atomic-wind/blocks/icon/render.php b/src/atomic-wind/blocks/icon/render.php index b5b6c3481..9823bd61c 100644 --- a/src/atomic-wind/blocks/icon/render.php +++ b/src/atomic-wind/blocks/icon/render.php @@ -332,8 +332,9 @@ function otter_atomic_wind_sanitize_custom_svg( $svg_code ) { $wrapper_attrs = get_block_wrapper_attributes(); +// Fallback size until the Tailwind utilities load, so the SVG does not paint at the browser default size. The size utilities override these attributes once their CSS is applied. // Safe: inner markup from plugin-bundled Lucide icons only. -echo '' . $aw_icons_map[ $icon ] // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped . ''; diff --git a/tests/test-atomic-wind-blocks.php b/tests/test-atomic-wind-blocks.php index f38665eca..125e4804c 100644 --- a/tests/test-atomic-wind-blocks.php +++ b/tests/test-atomic-wind-blocks.php @@ -425,6 +425,30 @@ public function test_icon_block_falls_back_to_circle_for_unknown_icon() { $this->assertStringContainsString( 'render_icon_block( + array( + 'icon' => 'zap', + ) + ); + + $this->assertStringContainsString( 'width="1em"', $result ); + $this->assertStringContainsString( 'height="1em"', $result ); + } + + public function test_icon_block_custom_svg_keeps_own_dimensions_without_default() { + $result = $this->render_icon_block( + array( + 'customSvgEnabled' => true, + 'customSvg' => '', + ) + ); + + $this->assertStringContainsString( 'width="32"', $result ); + $this->assertStringContainsString( 'height="32"', $result ); + $this->assertStringNotContainsString( '1em', $result ); + } + // ------------------------------------------------------- // render_animation_attrs // -------------------------------------------------------