You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astro v4.16.10
Node v18.20.3
System Linux (x64)
Package Manager unknown
Output static
Adapter none
Integrations astro-icon
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Hi! Thank you all for your work on this library, it's been super helpful in optimising icons and bringing them to my Astro site. 😇
In #246, the viewBox attribute was moved from <svg/> to <symbol/>. However, for non-inline icons, it appears that this only takes effect on the first occurrence of <Icon/>. Subsequent instances of <Icon/> retain their viewBox attribute, which is inconsistent behaviour.
That is,
{/* Put both of these `<Icon/>` instances, one after another, in the same Astro file: */}{/* This renders `<svg/>` _without_ a `viewBox` attribute */}<Iconname="square"/>{/* This renders `<svg/>` _with_ a `viewBox` attribute */}<Iconname="square"/>
I suspect the cause to be: includeSymbol: bool determines whether to remove the viewBox attribute. According to the below assignment, it will be false in subsequent usages of <Icon/> because i > 0.
The behaviour should be consistent. A consumer should be able to specify the same markup (<Icon name="square"/>) and expect them to render <svg/> that behaves the same — it should either omit the viewBox attribute across all instances, or include them across all instances.
Another suggestion is to add some sort of attribute/config to let users decide the viewBox behaviour.
What version of
astro-icon
are you using?v1.1.2
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Hi! Thank you all for your work on this library, it's been super helpful in optimising icons and bringing them to my Astro site. 😇
In #246, the
viewBox
attribute was moved from<svg/>
to<symbol/>
. However, for non-inline icons, it appears that this only takes effect on the first occurrence of<Icon/>
. Subsequent instances of<Icon/>
retain theirviewBox
attribute, which is inconsistent behaviour.That is,
I suspect the cause to be:
includeSymbol: bool
determines whether to remove the viewBox attribute. According to the below assignment, it will befalse
in subsequent usages of<Icon/>
becausei > 0
.astro-icon/packages/core/components/Icon.astro
Line 39 in 531db17
astro-icon/packages/core/components/Icon.astro
Lines 118 to 124 in 531db17
What's the expected result?
The behaviour should be consistent. A consumer should be able to specify the same markup (
<Icon name="square"/>
) and expect them to render<svg/>
that behaves the same — it should either omit theviewBox
attribute across all instances, or include them across all instances.Another suggestion is to add some sort of attribute/config to let users decide the
viewBox
behaviour.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-u6hdxa?file=src%2Fpages%2Findex.astro
The text was updated successfully, but these errors were encountered: