Skip to content
Open
Show file tree
Hide file tree
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 src/atomic-wind/blocks/icon/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<svg ' . $wrapper_attrs . ' viewBox="0 0 24 24" fill="none" stroke="currentColor" ' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<svg ' . $wrapper_attrs . ' width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" ' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
. 'stroke-width="2" stroke-linecap="round" stroke-linejoin="round">'
. $aw_icons_map[ $icon ] // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
. '</svg>';
24 changes: 24 additions & 0 deletions tests/test-atomic-wind-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,30 @@ public function test_icon_block_falls_back_to_circle_for_unknown_icon() {
$this->assertStringContainsString( '<circle ', $result );
}

public function test_icon_block_renders_builtin_icon_with_default_dimensions() {
$result = $this->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' => '<svg width="32" height="32" viewBox="0 0 10 10"><path d="M1 1h8v8H1z"/></svg>',
)
);

$this->assertStringContainsString( 'width="32"', $result );
$this->assertStringContainsString( 'height="32"', $result );
$this->assertStringNotContainsString( '1em', $result );
}

// -------------------------------------------------------
// render_animation_attrs
// -------------------------------------------------------
Expand Down