Re: DOM-Parsing innerHTML/outerHTML and namespaces

On Nov 11, 2014, at 10:58 AM, Dirk Schulze <dschulze@adobe.com> wrote:

> Hi,
> 
> I have some question to clarification the use of element.innerHTML on SVG embedded in HTML. Maybe it is the easiest to use some examples:
> 
> <html><svg><g></g></svg>
> <script>
> document.getElementsByTagName(’g’)[0].innerHTML = “<a></a>”;
> </script>
> </html>

This example should read document.getElementsByTagName(’g’)[0].innerHTML = “<a>”;

> 
> Does that even parse? Reading the spec, it probably should be parsed with the HTML parser and therefore it doesn’t matter if the <a> tag is closed or not.
> 
> Which namespace does <a> have here? SVG namespace? HTML namespace? The topic namespaces is not really sufficiently specified IMO. SVG NS is not even called out, just XML namespace but not in the context of element creation. Obviously there are more namespaces to consider than just SVG though.
> 
> Depending on the question above:
> 
> <html><svg></svg>
> <script>
> document.getElementsByTagName(’svg’)[0].outerHTML = “<a></a>”;
> </script>
> </html>
> 
> Now we create <a> with the SVGSVGElement which has the SVG namespace, what namespace does <a> have?
> 
> Greetings,
> Dirk

Received on Tuesday, 11 November 2014 19:08:50 UTC