Skip to content

inlineStyles plugin should not remove id attribute from target element#2066

Open
johnkenny54 wants to merge 3 commits intosvg:mainfrom
johnkenny54:issue-2065
Open

inlineStyles plugin should not remove id attribute from target element#2066
johnkenny54 wants to merge 3 commits intosvg:mainfrom
johnkenny54:issue-2065

Conversation

@johnkenny54
Copy link
Copy Markdown
Contributor

Removed code that deletes id attribute from elements.

Resolves #2065.

@strarsis
Copy link
Copy Markdown
Contributor

strarsis commented Aug 29, 2024

Wouldn't an option be better? Subsequent plugins do not have the context to clean up the ID attribute, as it is removed by inline styles as being then unnecessary, as its associated styles were directly applied to the element.
PR that adds the options: #1165

@johnkenny54
Copy link
Copy Markdown
Contributor Author

Having an option isn't safe and just adds complexity to the plugin. If the id is no longer referenced, it should be removed by cleanupIds. Currently cleanupIds disables itself in the presence of <style> elements, which is not ideal, but at least preferable to what many other plugins do, since it doesn't break anything. But there's no reason cleanupIds couldn't check the selectors to see which ids are referenced by styles.

folknor added a commit to folknor/svgo that referenced this pull request Feb 18, 2026
- fix pretty + disabled short tags formatting
  svg#2088
- fix(removeOffCanvasPaths): invalid removal when line path starts with relative move
  svg#2086
- inlineStyles should not remove id attribute from target element
  svg#2066
- fix: cleanupIds changes style IDs incorrectly
  svg#2057

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inlineStyles plugin should not remove id attribute from target element

2 participants