From 006f6b23c64e82128c72dec795a0dfbe6e289d37 Mon Sep 17 00:00:00 2001 From: bohdanprog Date: Thu, 31 Jul 2025 16:44:54 +0200 Subject: [PATCH] fix: prevent undefined override props from overriding SVG element props --- apps/common/test/Test2693.tsx | 27 +++++++++++++++++++++++++++ apps/common/test/index.tsx | 1 + src/xml.tsx | 5 ++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 apps/common/test/Test2693.tsx diff --git a/apps/common/test/Test2693.tsx b/apps/common/test/Test2693.tsx new file mode 100644 index 000000000..dc848d0b9 --- /dev/null +++ b/apps/common/test/Test2693.tsx @@ -0,0 +1,27 @@ +import {View} from 'react-native'; +import {SvgCss} from 'react-native-svg/css'; +import {SvgXml} from 'react-native-svg'; + +export default function Test2693() { + return ( + + + `} + /> + + + + + + `} + /> + + + ); +} diff --git a/apps/common/test/index.tsx b/apps/common/test/index.tsx index 381f2aaca..e61b465f6 100644 --- a/apps/common/test/index.tsx +++ b/apps/common/test/index.tsx @@ -37,6 +37,7 @@ import Test2455 from './Test2455'; import Test2471 from './Test2471'; import Test2520 from './Test2520'; import Test2670 from './Test2670'; +import Test2693 from './Test2693'; export default function App() { return ; diff --git a/src/xml.tsx b/src/xml.tsx index 073888c13..44f1eca12 100644 --- a/src/xml.tsx +++ b/src/xml.tsx @@ -54,9 +54,12 @@ export function SvgAst({ ast, override }: AstProps) { const { props, children } = ast; const Svg = tags.svg; + const cleanedOverrideProps = Object.fromEntries( + Object.entries(override || {}).filter(([_, value]) => value !== undefined) + ); return ( - + {children} );