diff --git a/src/Icons/CHANGELOG.md b/src/Icons/CHANGELOG.md index 71eb76d0f2..2868a9ae64 100644 --- a/src/Icons/CHANGELOG.md +++ b/src/Icons/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.20.0 - Add `aliases` configuration option to define icon alternative names. +- Fix `Icon` component to accept `integer` or `float` attributes. ## 2.19.0 diff --git a/src/Icons/src/Icon.php b/src/Icons/src/Icon.php index 41883a9825..225460c20b 100644 --- a/src/Icons/src/Icon.php +++ b/src/Icons/src/Icon.php @@ -189,8 +189,8 @@ public function withAttributes(array $attributes): self throw new \InvalidArgumentException(\sprintf('Invalid attribute name "%s".', $name)); } - if (!\is_string($value) && !\is_bool($value)) { - throw new \InvalidArgumentException(\sprintf('Invalid value type for attribute "%s". Boolean or string allowed, "%s" provided. ', $name, get_debug_type($value))); + if (!\is_string($value) && !\is_bool($value) && !\is_int($value) && !\is_float($value)) { + throw new \InvalidArgumentException(\sprintf('Invalid value type for attribute "%s". Boolean, string, int or float allowed, "%s" provided. ', $name, get_debug_type($value))); } } diff --git a/src/Icons/tests/Fixtures/templates/template1.html.twig b/src/Icons/tests/Fixtures/templates/template1.html.twig index 9824703029..096a3d5333 100644 --- a/src/Icons/tests/Fixtures/templates/template1.html.twig +++ b/src/Icons/tests/Fixtures/templates/template1.html.twig @@ -2,8 +2,10 @@
  • {{ ux_icon('user', {class: 'h-8 w-8'}) }}
  • {{ ux_icon('user', {"aria-label": "AriaLabel"}) }}
  • {{ ux_icon('sub:check', {'data-action': 'string "with" quotes'}) }}
  • +
  • {{ ux_icon('sub:check', { height: 24, width: "24" }) }}
  • {{ ux_icon('iconamoon:3d-duotone') }}
  • +
  • {{ ux_icon('iconamoon:3d-duotone', { height: 24, width: "24" }) }}
  • diff --git a/src/Icons/tests/Integration/RenderIconsInTwigTest.php b/src/Icons/tests/Integration/RenderIconsInTwigTest.php index 0522a916f5..8789f29a15 100644 --- a/src/Icons/tests/Integration/RenderIconsInTwigTest.php +++ b/src/Icons/tests/Integration/RenderIconsInTwigTest.php @@ -29,10 +29,12 @@ public function testRenderIcons(): void
  • +
  • +
  • HTML, trim($output)