software-mansion/react-native-svg

Inherit Defs from Parent SVG

Offen

#1.284 geöffnet am 13.02.2020

 (8 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (1.076 Forks)batch import
enhancementgood first issuehelp wantedstale

Repository-Metriken

Stars
 (7.107 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Feature Request

On the web, if you have an svg within another svg, you can reference the defs in the parent svg from the child - ids are global after all

Take this example,

<svg>
  <defs>
    <path id="a" d="…"/>
    <path id="b" d="…"/>
    <path id="c" d="…"/>
  </defs>
  <use href="#a"/>
  <svg x=…>
    <use href="#b"/>
  </svg>
  <use href="#c"/>
</svg>

This crashes - and it does make sense why it does

But it might be possible to fix this use-case by allowing the child to look up through the svg parents to find the relevant area

Why it is needed

This shows up a lot with the new mathjax 3 svg output using fontCache: 'local' - large brackets are represented in the same format as the example I gave above

Possible implementation

If RNSVGSvgView held an optional reference to a parent svg, this might be possible. Unsure of Android implementation

Code sample

Refer to the above code sample

Contributor Guide