Skip to content

Commit 4886135

Browse files
authored
fix: do not parse id as number in any case (#2563)
# Summary When using `SvgXml` or `SvgCss`, an `id` attribute gets converted into a `number` instead of a `string`, which causes a crash because the native side expects a string value. ```js import {SvgXml} from 'react-native-svg'; import {SvgCss} from 'react-native-svg/css'; ``` ## Test Plan This example should not crash: ```jsx import {SvgCss} from 'react-native-svg/css'; const svgXml = ` <svg width="100" height="100" viewBox="0 0 100 100"> <filter x="0%" y="0%" width="100" height="100" id="0123456789"> <feFlood flood-color="red" /> </filter> <circle cx="50" cy="50" r="50" filter="url(#0123456789)" /> </svg> `; function Example() { return <SvgCss xml={svgXml} />; } ```
1 parent 3b5c5f0 commit 4886135

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/xml.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export function parse(source: string, middleware?: Middleware): JsxAST | null {
458458
allowSpaces();
459459

460460
value = getAttributeValue();
461-
if (!isNaN(+value) && value.trim() !== '') {
461+
if (name !== 'id' && !isNaN(+value) && value.trim() !== '') {
462462
value = +value;
463463
}
464464
}

0 commit comments

Comments
 (0)