fix(react-native): strip orphaned url(#id) attributes and <use> elements after unsupported <defs> nodes are dropped
#1006
+140
−0
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.
Problem
When SVGR runs in React-Native projects it removes unsupported SVG nodes such as
<filter>,<clipPath>, and<mask>.The related attributes (
filter="url(#…)",clipPath="url(#…)", etc.) and<use href="#…">references remain in the output. Chromium-based browsers ignore these dangling references, but Safari refuses to paint any element that targets a missing definition, producing partially invisible graphics.Fix
The
babel-plugin-transform-react-native-svgvisitor now:• delete attributes whose value is
url(#id)when the referencedidno longer exists in the AST,• delete
<use>elements whosehref/xlinkHreftarget a missingid.This guarantees that the generated component never contains broken references, restoring correct rendering in Safari and other strict SVG user agents.
Impact
<defs>entries now render consistently across browsers.Checklist