-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
React fails to render SVG children in Edge/IE #5061
Comments
Update: I've just seen these symptoms in Microsoft Edge as well, which makes it much more serious. I'll be back in a bit with more research... |
Confirmed: the same problem affects Edge, IE (tested 11-9), and PhantomJS 2.0. React 0.13 and earlier has the same problem, but does not report any error. It is possible to add an SVG element using vanilla DOM methods in these browsers, e.g.: var circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
circle.setAttribute("fill", "red");
circle.setAttribute("r", 50);
circle.setAttribute("cx", 50);
circle.setAttribute("cy", 50);
document.getElementById("gElement").appendChild(circle); |
My theory as to what's going on here is that SVG elements do not support the |
👍 I am also having this issue, trying to use React to render an |
We're moving towards the use of If you wanted to get fancy you could do something hacky that updates your svg but otherwise renders into something else… in theory something like this (caveat that I haven't run it nor will I support it): function renderReactIntoSVG(element, node) {
var mynode = document.createElement('div');
ReactDOM.render(<SVGReparenter into={node}>{element}</SVGReparenter>, mynode);
}
SVGReparenter = React.createClass({
reparent: function() {
// assume you only have a single child node which would map up to
// expectations if you're subbing this code in for a React.render().
this.props.into.replaceChild(
this.props.into.firstChild,
this.refs.root.firstChild.cloneNode(true)
);
}
componentDidUpdate: function() {
this.reparent();
},
componentDidMount: function() {
this.reparent();
},
componentWillUnmount: function() {
// cleanup after ourselves
this.props.into.removeChild(this.props.into.firstChild);
}
render: function() {
// TODO: maybe use callback refs
return <svg ref="root">{this.props.children}</svg>
}
}) |
Yea, that would solve this too (that's effectively effectively what I wrote above 😁). But I do think we'll be moving away from innerHTML, hopefully before next release. |
👍 Any updates on this? I as well can't use |
I think it works in master/future. http://jsfiddle.net/zcotr9hm/ If I'm wrong, let me know and we can re-investigate. |
Thanks @jimfb, it seems to me that it's not fixed in latest ( |
Yeah. I think that I am seeing the same problem. React 15.6.1 on IE 11 and Edge Update: Nevermind. What I am seeing is a bug with Edge and IE 11 |
In my case Microsoft Edge 44.19041.423.0, does not support spread operator. |
Here's a gist that illustrates the issue.
index.html
will work as expected (rendering a red circle) in most browsers. If you run thephantom-run.js
script in PhantomJS 2.0 (assuming you have the page hosted atlocalhost:3000
), however, it throws this error:and fails to insert the circle.
The text was updated successfully, but these errors were encountered: