Skip to content

Commit

Permalink
fix(removeDesc): removeAny should be disabled by default (#1806)
Browse files Browse the repository at this point in the history
As the description of the plugin states, it should only remove the
description if we can see it's just editor attribution, since this
element is used for accessibility.

In general, accessibility is more important than optimizations, so while
I could update the documentation to reflect this behavior, I believe the
default should be changed back.
  • Loading branch information
SethFalco committed Oct 4, 2023
1 parent 027e110 commit e529c66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
12 changes: 6 additions & 6 deletions lib/svgo-node.test.js
Expand Up @@ -17,7 +17,7 @@ describeLF('with LF line-endings', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -34,7 +34,7 @@ describeLF('with LF line-endings', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -53,7 +53,7 @@ describeLF('with LF line-endings', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -74,7 +74,7 @@ describeCRLF('with CRLF line-endings', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -91,7 +91,7 @@ describeCRLF('with CRLF line-endings', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -110,7 +110,7 @@ describeCRLF('with CRLF line-endings', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand Down
19 changes: 8 additions & 11 deletions lib/svgo.test.js
Expand Up @@ -11,7 +11,7 @@ test('allow to setup default preset', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand Down Expand Up @@ -46,7 +46,7 @@ test('allow to disable and customize plugins in preset', () => {
overrides: {
removeXMLProcInst: false,
removeDesc: {
removeAny: false,
removeAny: true,
},
},
},
Expand All @@ -57,9 +57,6 @@ test('allow to disable and customize plugins in preset', () => {
expect(data).toMatchInlineSnapshot(`
"<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
</desc>
<circle cx="60" cy="60" r="50" fill="red"/>
</svg>
"
Expand Down Expand Up @@ -104,7 +101,7 @@ describe('allow to configure EOL', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -123,7 +120,7 @@ describe('allow to configure EOL', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -142,7 +139,7 @@ describe('allow to configure EOL', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle cx="60" cy="60" fill="#ff0000" r="50"/>
</svg>
Expand All @@ -163,7 +160,7 @@ describe('allow to configure final newline', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle cx="60" cy="60" r="50" fill="#ff0000"/>
</svg>
Expand All @@ -180,7 +177,7 @@ describe('allow to configure final newline', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand All @@ -199,7 +196,7 @@ describe('allow to configure final newline', () => {
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 120 120">
<desc>
Not standard description
Created with love
</desc>
<circle fill="#ff0000" cx="60" cy="60" r="50"/>
</svg>
Expand Down
2 changes: 1 addition & 1 deletion plugins/removeDesc.js
Expand Up @@ -19,7 +19,7 @@ const standardDescs = /^(Created with|Created using)/;
* @type {import('./plugins-types').Plugin<'removeDesc'>}
*/
exports.fn = (root, params) => {
const { removeAny = true } = params;
const { removeAny = false } = params;
return {
element: {
enter: (node, parentNode) => {
Expand Down

0 comments on commit e529c66

Please sign in to comment.