Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly-inserted SVG elements do not render on component update #311

Closed
sklobovskaya opened this issue Sep 3, 2013 · 3 comments
Closed

Newly-inserted SVG elements do not render on component update #311

sklobovskaya opened this issue Sep 3, 2013 · 3 comments

Comments

@sklobovskaya
Copy link

Components which try to render SVG elements, such as <path>, <text>, <g>, etc. that must be inserted into a parent <svg> do not get rendered by the browser. I assume this is because the function renderMarkup() uses innerHTML, and new SVG elements cannot be created this way -- the browser won't render them standalone.

One quick fix is to add these SVG elements to markupWrap and wrap them in an <svg> tag and then extract them, but there may be a more appropriate/elegant solution.

I realize SVGs aren't React's focus, but I thought I'd point it out anyway, just in case. Thanks for the great work so far.

@sophiebits
Copy link
Collaborator

Adding them to markupWrap would seem to make sense to me.

(I also hear that Facebook has React bindings for ART which looks to be a cross-browser drawing library. I've been nudging them to release the bindings.)

@zpao
Copy link
Member

zpao commented Sep 3, 2013

@sklobovskaya thanks for pointing this out! I'm going to defer to @sebmarkbage here since he's done most of our SVG-related work.

@sebmarkbage
Copy link
Collaborator

That makes sense. We should add some more markupWraps.

sophiebits added a commit to sophiebits/react that referenced this issue Oct 9, 2013
Forcing wrapping seems necessary here: I compared a <circle> created within a <div> with a <circle> created inside an <svg> and they appear to have exactly the same properties with the exception of .parentNode (and .parentElement), yet the former refuses to show up when appended to an <svg> element. As such, I can't find any useful way to write a unit test (testing getMarkupWrap's output doesn't seem particularly useful to me).

Fixes facebook#311.

Test Plan:
With a component that adds a <circle> after mounting (such as http://jsfiddle.net/spicyj/hxFVe/), verify that the circle appears in both Chrome and IE9.
@zpao zpao closed this as completed in 7909c3e Oct 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants