I have a very simple jsfiddle here:
http://jsfiddle.net/9uS3u/
It consists of this html:
<svg></svg>
And this javascript:
alert(document.getElementsByTagName("svg")[0].children);
I expect it to alert something like "[Object HtmlCollection]". In IE 11 though, it gives "undefined". It seems that the children
property is not defined on SVGSVGElement
despite claims on the internet that IE 11 does support svg. What gives?
I think the answer is that the children
property is not yet officially part of the DOM specifications, where you'll find childNodes
on the Node interface, but not children
(neither on the Element interface). For further info (especially the difference between children
and childNodes
), have a look at this other answer.
In my research so far, svg is supported by IE as an SVGGElement, where as the children property is part of an HTMLCollection element. All the other browsers seem to treat SVGs as HTMLCollections. Why IE treats SVG differently than other browsers, I can't answer, but it is annoying and causing me to write all sorts of work-arounds to manipulate SVGs on the fly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With