diff --git a/plugins/inlineStyles.js b/plugins/inlineStyles.js index 26b4314b8..0928a2bbe 100644 --- a/plugins/inlineStyles.js +++ b/plugins/inlineStyles.js @@ -293,7 +293,7 @@ export const fn = (root, params) => { return; } - // clean up matched class + ID attribute values + // clean up matched class values for (const selector of sortedSelectors) { if (selector.matchedElements == null) { continue; @@ -333,23 +333,6 @@ export const fn = (root, params) => { } else { selectedEl.attributes.class = Array.from(classList).join(' '); } - - // ID - const firstSubSelector = selector.node.children.first; - if ( - firstSubSelector?.type === 'IdSelector' && - selectedEl.attributes.id === firstSubSelector.name && - !selectors.some((selector) => - includesAttrSelector( - selector.item, - 'id', - firstSubSelector.name, - true, - ), - ) - ) { - delete selectedEl.attributes.id; - } } } diff --git a/test/plugins/inlineStyles.16.svg.txt b/test/plugins/inlineStyles.16.svg.txt index 31f548af2..822700015 100644 --- a/test/plugins/inlineStyles.16.svg.txt +++ b/test/plugins/inlineStyles.16.svg.txt @@ -27,7 +27,7 @@ button - + diff --git a/test/plugins/inlineStyles.30.svg.txt b/test/plugins/inlineStyles.30.svg.txt new file mode 100644 index 000000000..ae503ea66 --- /dev/null +++ b/test/plugins/inlineStyles.30.svg.txt @@ -0,0 +1,20 @@ +inlineStyles plugin should not remove id attribute from target element. + +See: https://github.com/svg/svgo/issues/2065 + +=== + + + + + + + +@@@ + + + + +