software-mansion/react-native-svg

Inherit Defs from Parent SVG

オープン

#1,284 opened on 2020/02/13

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)Java (1,076 件のフォーク)batch import
enhancementgood first issuehelp wantedstale

Repository metrics

Stars
 (7,107 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド