Commit eb0663b
fix: keep viewBox on the svg wrapper instead of stripping it (#298)
* fix: keep viewBox on the svg wrapper for every icon instance
PR #286 made viewBox stripping consistent across repeated instances by
removing it everywhere for non-inline rendering. As Chris pointed out,
viewBox does more than size the icon: attributes like preserveAspectRatio
have no effect without it. Achieve the same consistency by always keeping
the viewBox instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: anchor use element to the icon's viewBox rect
Keeping viewBox on the wrapper alone reintroduces the clipping from #212:
a <use> with no x/y/width/height generates its viewport at user-space (0,0)
sized to 100% of the wrapper, so icons whose viewBox has a non-zero
min-x/min-y render shifted and cropped.
Pin the <use> to the symbol's viewBox rect so the reference is an identity
placement, and source the symbol's viewBox from the icon data rather than
the merged props so a per-instance override no longer leaks onto every
other instance of the same icon.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: only anchor the use element for offset-origin icons
The generated <use> viewport already defaults to the symbol's viewBox rect
when that rect starts at the origin, which covers essentially every icon.
Emit x/y/width/height only when the icon's viewBox has a non-zero
min-x/min-y, so the common case renders exactly the markup it did before.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: keep the symbol viewBox only where it does work
With the wrapper's viewBox restored, a symbol viewBox is redundant for an
icon whose own viewBox starts at the origin: a bare <use> already generates
a viewport covering the whole wrapper, and the artwork lands on it 1:1.
It stays for offset-origin icons, where it is the only way to decouple
viewport placement from the artwork's coordinates, since <use> x/y translate
the referenced content along with the viewport.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* refactor: trim viewBox comments down to the why
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent d90facd commit eb0663b
2 files changed
Lines changed: 17 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| |||
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
156 | | - | |
| 162 | + | |
157 | 163 | | |
158 | | - | |
| 164 | + | |
159 | 165 | | |
160 | 166 | | |
161 | 167 | | |
| |||
0 commit comments