software-mansion/react-native-svg

Inherit Defs from Parent SVG

Open

#1,284 创建于 2020年2月13日

在 GitHub 查看
 (8 评论) (0 反应) (0 负责人)Java (1,076 fork)batch import
enhancementgood first issuehelp wantedstale

仓库指标

Star
 (7,107 star)
PR 合并指标
 (平均合并 9天 18小时) (30 天内合并 1 个 PR)

描述

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

贡献者指南