Skip to content

Commit

Permalink
fix: fix duplicate plugin/preset detected error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Wen committed Jul 19, 2022
1 parent d2a2f07 commit efc8466
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/babel-preset/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ describe('preset', () => {
`)
})

it('handles descProp and titleProp', () => {
expect(
testPreset('<svg></svg>', {
titleProp: true,
descProp: true,
}),
).toMatchInlineSnapshot(`
"import * as React from \\"react\\";
const SvgComponent = ({
title,
titleId,
desc,
descId
}) => <svg aria-labelledby={titleId} aria-describedby={descId}>{desc ? <desc id={descId}>{desc}</desc> : null}{title ? <title id={titleId}>{title}</title> : null}</svg>;
export default SvgComponent;"
`)
})

it('handles replaceAttrValues', () => {
expect(
testPreset('<svg a="#000" b="#fff" />', {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const plugin = (_: ConfigAPI, opts: Options) => {
}

if (opts.descProp) {
plugins.push([svgDynamicTitle, { tag: 'desc' }])
plugins.push([svgDynamicTitle, { tag: 'desc' }, 'desc'])
}

if (opts.native) {
Expand Down

0 comments on commit efc8466

Please sign in to comment.