- From: Simon Pieters <simonp@opera.com>
- Date: Tue, 11 Nov 2014 21:55:27 +0100
- To: "www-dom@w3.org" <www-dom@w3.org>, "Dirk Schulze" <dschulze@adobe.com>
On Tue, 11 Nov 2014 19:58:39 +0100, 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>
>
> 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.
Right. But it's a parse error to omit the end tag (except if the start tag
has a trailing slash).
> 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.
https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
->
https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept-parse-fragment
(context element is <g>)
->
https://html.spec.whatwg.org/multipage/syntax.html#html-fragment-parsing-algorithm
(context is <g>)
https://html.spec.whatwg.org/multipage/syntax.html#adjusted-current-node
(adjusted current node is <g>)
https://html.spec.whatwg.org/multipage/syntax.html#tree-construction-dispatcher
("Process the token according to the rules given in the section for
parsing tokens in foreign content.")
https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inforeign
("Any other start tag" ... "Insert a foreign element for the token, in the
same namespace as the adjusted current node.")
> 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?
Same as above.
HTH,
--
Simon Pieters
Opera Software
Received on Tuesday, 11 November 2014 20:55:58 UTC