From 00e84ead96d89bcbd072b9585b4db1365e392d33 Mon Sep 17 00:00:00 2001 From: Michael Gruben Date: Sat, 14 Nov 2020 23:04:46 +0100 Subject: [PATCH] fix: prevent removing the namespace by svgr ([#475](https://github.com/gregberge/svgr/issues/475) (#498) Co-authored-by: Michael Gruben --- packages/babel-preset/src/index.js | 2 +- .../cli/src/__snapshots__/index.test.js.snap | 109 ++++++++++++++---- .../cli/src/__snapshots__/util.test.js.snap | 10 +- .../src/__snapshots__/convert.test.js.snap | 96 +++++++++++---- .../src/__snapshots__/index.test.js.snap | 3 +- packages/plugin-jsx/src/index.test.js | 4 +- .../src/__snapshots__/index.test.js.snap | 9 +- .../src/__snapshots__/index.test.js.snap | 9 +- 8 files changed, 182 insertions(+), 60 deletions(-) diff --git a/packages/babel-preset/src/index.js b/packages/babel-preset/src/index.js index 68e66f10..bb656fc2 100644 --- a/packages/babel-preset/src/index.js +++ b/packages/babel-preset/src/index.js @@ -28,7 +28,7 @@ function replaceMapToValues(replaceMap) { } const plugin = (api, opts) => { - let toRemoveAttributes = ['xmlns', 'xmlnsXlink', 'version'] + let toRemoveAttributes = ['version'] let toAddAttributes = [] if (opts.svgProps) { diff --git a/packages/cli/src/__snapshots__/index.test.js.snap b/packages/cli/src/__snapshots__/index.test.js.snap index bfb70700..c6a57053 100644 --- a/packages/cli/src/__snapshots__/index.test.js.snap +++ b/packages/cli/src/__snapshots__/index.test.js.snap @@ -9,7 +9,7 @@ exports[`cli should not override config with cli defaults 1`] = ` "import * as React from \\"react\\"; function SvgFile() { - return {\\"Rectangle 5\\"}{\\"Created with Sketch.\\"}; + return {\\"Rectangle 5\\"}{\\"Created with Sketch.\\"}; } export default SvgFile; @@ -23,7 +23,12 @@ exports[`cli should support --prettier-config as file 1`] = ` function SvgFile(props) { return ( - + ) @@ -39,7 +44,12 @@ exports[`cli should support --prettier-config as json 1`] = ` function SvgFile(props) { return ( - + ) @@ -55,7 +65,7 @@ exports[`cli should support --svgo-config as file 1`] = ` function SvgFile(props) { return ( - + {'Rectangle 5'} @@ -72,7 +82,7 @@ exports[`cli should support --svgo-config as json 1`] = ` function SvgFile(props) { return ( - + {'Rectangle 5'} @@ -138,7 +148,7 @@ exports[`cli should support stdin filepath 1`] = ` function SvgFile(props) { return ( - + ) @@ -154,7 +164,7 @@ exports[`cli should support various args: --expand-props none 1`] = ` function SvgFile() { return ( - + ) @@ -170,7 +180,7 @@ exports[`cli should support various args: --expand-props start 1`] = ` function SvgFile(props) { return ( - + ) @@ -186,7 +196,13 @@ exports[`cli should support various args: --icon 1`] = ` function SvgFile(props) { return ( - + ) @@ -203,7 +219,7 @@ import Svg, { Path } from 'react-native-svg' function SvgFile() { return ( - + ) @@ -220,7 +236,13 @@ import Svg, { Path } from 'react-native-svg' function SvgFile(props) { return ( - + ) @@ -237,7 +259,13 @@ import Svg, { Path } from 'react-native-svg' function SvgFile(props, svgRef) { return ( - + ) @@ -255,7 +283,7 @@ import Svg, { Path } from 'react-native-svg' function SvgFile(props) { return ( - + ) @@ -271,7 +299,7 @@ exports[`cli should support various args: --no-dimensions 1`] = ` function SvgFile(props) { return ( - + ) @@ -286,7 +314,7 @@ exports[`cli should support various args: --no-prettier 1`] = ` "import * as React from \\"react\\"; function SvgFile(props) { - return ; + return ; } export default SvgFile; @@ -298,7 +326,14 @@ exports[`cli should support various args: --no-svgo 1`] = ` function SvgFile(props) { return ( - + {'Rectangle 5'} {'Created with Sketch.'} @@ -339,7 +374,13 @@ exports[`cli should support various args: --ref 1`] = ` function SvgFile(props, svgRef) { return ( - + ) @@ -356,7 +397,7 @@ exports[`cli should support various args: --replace-attr-values "#063855=current function SvgFile(props) { return ( - + ) @@ -372,7 +413,14 @@ exports[`cli should support various args: --svg-props "hidden={true},id=hello" 1 function SvgFile(props) { return ( -