File tree 2 files changed +21
-1
lines changed
packages/babel-preset/src
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,26 @@ describe('preset', () => {
132
132
` )
133
133
} )
134
134
135
+ it ( 'handles descProp and titleProp' , ( ) => {
136
+ expect (
137
+ testPreset ( '<svg></svg>' , {
138
+ titleProp : true ,
139
+ descProp : true ,
140
+ } ) ,
141
+ ) . toMatchInlineSnapshot ( `
142
+ "import * as React from \\"react\\";
143
+
144
+ const SvgComponent = ({
145
+ title,
146
+ titleId,
147
+ desc,
148
+ descId
149
+ }) => <svg aria-labelledby={titleId} aria-describedby={descId}>{desc ? <desc id={descId}>{desc}</desc> : null}{title ? <title id={titleId}>{title}</title> : null}</svg>;
150
+
151
+ export default SvgComponent;"
152
+ ` )
153
+ } )
154
+
135
155
it ( 'handles replaceAttrValues' , ( ) => {
136
156
expect (
137
157
testPreset ( '<svg a="#000" b="#fff" />' , {
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ const plugin = (_: ConfigAPI, opts: Options) => {
143
143
}
144
144
145
145
if ( opts . descProp ) {
146
- plugins . push ( [ svgDynamicTitle , { tag : 'desc' } ] )
146
+ plugins . push ( [ svgDynamicTitle , { tag : 'desc' } , 'desc' ] )
147
147
}
148
148
149
149
if ( opts . native ) {
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Jul 19, 2022
Successfully deployed to the following URLs:
svgr – ./
api.react-svgr.com
svgr-gregberge.vercel.app
svgr-git-main-gregberge.vercel.app