@@ -23,7 +23,6 @@ fn to_jsx<'arena>(dom: &'arena Node<'arena>) -> JSXElementChild {
2323 attrs : attrs
2424 . borrow ( )
2525 . iter ( )
26- . filter ( |attr| matches ! ( attr. name. ns, ns!( ) ) )
2726 . map ( |attr| {
2827 JSXAttrOrSpread :: JSXAttr ( JSXAttr {
2928 name : JSXAttrName :: Ident ( IdentName :: new (
@@ -470,18 +469,18 @@ fn jsx_attr_name<'a>(name: &'a ExpandedName) -> &'a str {
470469 expanded_name ! ( "" , "x" ) => "x" ,
471470 expanded_name ! ( "" , "xchannelselector" ) => "xChannelSelector" ,
472471 expanded_name ! ( "" , "x-height" ) => "xHeight" ,
473- expanded_name ! ( "" , "xlink: actuate") => "xlinkActuate" ,
474- expanded_name ! ( "" , "xlink: arcrole") => "xlinkArcrole" ,
475- expanded_name ! ( "" , "xlink: href") => "xlinkHref" ,
476- expanded_name ! ( "" , "xlink: role") => "xlinkRole" ,
477- expanded_name ! ( "" , "xlink: show") => "xlinkShow" ,
478- expanded_name ! ( "" , "xlink: title") => "xlinkTitle" ,
479- expanded_name ! ( "" , "xlink: type") => "xlinkType" ,
480- expanded_name ! ( "" , "xml: base") => "xmlBase" ,
481- expanded_name ! ( "" , "xml: lang") => "xmlLang" ,
482- expanded_name ! ( "" , "xmlns" ) => "xmlns" ,
483- expanded_name ! ( "" , "xml: space") => "xmlSpace" ,
484- expanded_name ! ( "" , "xmlns: xlink") => "xmlnsXlink" ,
472+ expanded_name ! ( xlink " actuate") => "xlinkActuate" ,
473+ expanded_name ! ( xlink " arcrole") => "xlinkArcrole" ,
474+ expanded_name ! ( xlink " href") => "xlinkHref" ,
475+ expanded_name ! ( xlink " role") => "xlinkRole" ,
476+ expanded_name ! ( xlink " show") => "xlinkShow" ,
477+ expanded_name ! ( xlink " title") => "xlinkTitle" ,
478+ expanded_name ! ( xlink " type") => "xlinkType" ,
479+ expanded_name ! ( xml " base") => "xmlBase" ,
480+ expanded_name ! ( xml " lang") => "xmlLang" ,
481+ expanded_name ! ( xmlns "xmlns" ) => "xmlns" ,
482+ expanded_name ! ( xml " space") => "xmlSpace" ,
483+ expanded_name ! ( xmlns " xlink") => "xmlnsXlink" ,
485484 expanded_name ! ( "" , "y1" ) => "y1" ,
486485 expanded_name ! ( "" , "y2" ) => "y2" ,
487486 expanded_name ! ( "" , "y" ) => "y" ,
@@ -708,6 +707,10 @@ impl<'de> Deserialize<'de> for ExpandProps {
708707}
709708
710709pub fn to_component < ' arena > ( dom : & ' arena Node < ' arena > , options : JsxOptions ) -> Program {
710+ if let Some ( svg) = dom. find ( expanded_name ! ( svg "svg" ) ) {
711+ svg. remove_attribute ( expanded_name ! ( xmlns "xmlns" ) ) ;
712+ }
713+
711714 if options. dimensions {
712715 match & options. icon {
713716 Icon :: None => { }
@@ -1200,6 +1203,25 @@ mod tests {
12001203 ..Default :: default ( )
12011204 } ,
12021205 ) ;
1206+
1207+ test (
1208+ r#"
1209+ <?xml version="1.0" encoding="UTF-8"?>
1210+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
1211+ <text xml:space="preserve"> foo </text>
1212+ </svg>
1213+ "# ,
1214+ indoc ! { r#"
1215+ export default function SvgComponent(props) {
1216+ return <svg viewBox="0 0 100 100" {...props}>
1217+ <text xmlSpace="preserve"> foo </text>
1218+ </svg>;
1219+ }
1220+ "# } ,
1221+ JsxOptions {
1222+ ..Default :: default ( )
1223+ } ,
1224+ ) ;
12031225 }
12041226
12051227 #[ test]
0 commit comments