Skip to content

Commit a4ce09a

Browse files
committed
feat: do not remove style tag
Removing style tag is an optimization, SVGO can do it better than us. BREAKING CHANGE: Style tag will no longer be automatically removed. SVGO should handle it correctly using "inlineStyles" plugin. If you want to remove them, enable "removeStyleElement" plugin in your SVGO config. Closes #191
1 parent f71aa7a commit a4ce09a

6 files changed

Lines changed: 2 additions & 53 deletions

File tree

packages/core/src/__snapshots__/convert.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ const SvgComponent = props => (
428428
<path d=\\"M51 37L37 51\\" id=\\"Shape\\" />
429429
<path d=\\"M51 51L37 37\\" />
430430
</g>
431+
<style />
431432
</g>
432433
</svg>
433434
)

packages/core/src/h2x/__snapshots__/removeStyle.test.js.snap

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/core/src/h2x/removeStyle.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/core/src/h2x/removeStyle.test.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/core/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export { default as emSize } from './h2x/emSize'
88
export { default as expandProps } from './h2x/expandProps'
99
export { default as removeComments } from './h2x/removeComments'
1010
export { default as removeDimensions } from './h2x/removeDimensions'
11-
export { default as removeStyle } from './h2x/removeStyle'
1211
export { default as replaceAttrValues } from './h2x/replaceAttrValues'
1312
export { default as stripAttribute } from './h2x/stripAttribute'
1413
export { default as svgAttributes } from './h2x/svgAttributes'

packages/core/src/plugins/h2x.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
expandProps,
66
removeComments,
77
removeDimensions,
8-
removeStyle,
98
replaceAttrValues,
109
stripAttribute,
1110
svgAttributes,
@@ -16,12 +15,7 @@ import {
1615
} from '..'
1716

1817
function configToPlugins(config) {
19-
const plugins = [
20-
jsx,
21-
stripAttribute('xmlns'),
22-
removeComments(),
23-
removeStyle(),
24-
]
18+
const plugins = [jsx, stripAttribute('xmlns'), removeComments()]
2519
if (config.replaceAttrValues)
2620
plugins.push(replaceAttrValues(config.replaceAttrValues))
2721
if (!config.dimensions) plugins.push(removeDimensions())

0 commit comments

Comments
 (0)