|
|
|
|
|
by kyle-rb
2335 days ago
|
|
>Using element.innerHTML is incorrect as SVG elements shouldn't have a innerHTML property Is that definitely the case? Chrome, Firefox, and Safari all return a value for the innerHTML property of an element in an SVG document. This W3C spec [0] specifically mentions XML documents in addition to HTML documents. And as I understand it, it seems like embedded SVG elements also inherit from the Element interface which includes InnerHTML. IE11 might also be correct, following an older spec, but I don't think you can jump to the conclusion that Chrome is wrong just because the property is called innerHTML. [0] https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin |
|
I assumed that innerHTML must have been wrong because textContent works in all the browsers I have tried it on whereas innerHTML doesn't work. A cursory search textContent vs innerHTML seemed to suggest textContent was the correct way.
It looks like it isn't a simple case of IE11 (I haven't had a chance to test on 9 & 10 yet) being correct and the others being incorrect. Thanks for the info.