fix(removeUnknownsAndDefaults): keep href on the a element#2234
Open
sjh9714 wants to merge 1 commit into
Open
Conversation
caghand
approved these changes
Jul 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2230.
removeUnknownsAndDefaultsdeleted thehrefattribute from<a>elements, solinks in an optimized SVG stopped working:
In
_collections.js,elems.apulls in thexlinkattribute group — which iswhy
xlink:hrefsurvives — but its ownattrsset never listed the SVG 2href, so the plugin treated it as unknown. Twelve other entries in the samefile already list
'href'next to'xlink:href'(image,use,linearGradient,feImage,filter,mpath,script, …), soalooks likean oversight.
Changes
'href'toelems.a.attrsinplugins/_collections.js(one line,alphabetically placed to match the surrounding entries)
test/plugins/removeUnknownsAndDefaults.18.svg.txtcovering both<a href>and<a xlink:href>; thexlink:hrefcase is the control and passedbefore this change too
Testing
yarn jest test/plugins/_index.test.js -t 'removeUnknownsAndDefaults'yarn testyarn lintyarn test:typesThe new fixture fails on
main(- <a href="https://developer.mozilla.org/">/+ <a>) and passes with the change. I did not runyarn test:regressionoryarn test:bundleslocally.Note on #2062
#2061/#2062 is the same class of bug for animation elements. That PR takes a
different route (a new
animationTargetElementgroup) and does not touchelems.a, so this is not a duplicate — but it also adds aremoveUnknownsAndDefaults.18.svg.txt..18is the next free index onmain;happy to renumber if #2062 lands first.