[whatwg] innerHTML in HTML documents with multiple namespaces

Thomas Broyer t.broyer at gmail.com
Mon Apr 2 07:47:18 PDT 2007


2007/4/2, Asbjørn Ulsberg:
> On Tue, 27 Mar 2007 16:39:05 +0200, Thomas Broyer wrote:
>
> > In other words, what should document.body.innerHTML end with after this
> > script: var svg_svg =
> > document.createElementNS("http://www.w3.org/2000/svg",
> > "svg:svg"); document.body.appendChild(svg_svg);
>
> As long as the result stays well-formed and qualified, does it really
> matter?

Probably not, but if HTML5 defines serialization, it should cover
every case (even saying "this is undefined").
I mean, what's the purpose of defining an algorithm if it's not
well-defined, i.e. if it's not implementable without some guess work?

> > Should it end with "<svg></svg>" or "<svg:svg></svg:svg>"? (Firefox
> > would have "<svg></svg>")
>
> Imo, it would be <svg xmlns="http://www.w3.org/2000/svg"></svg> or
> <svg:svg xmlns:svg="http://www.w3.org/2000/svg"></svg:svg>. The
> deserialization of those XML fragments produce the same DOM and are thus
> equal. If the namespace URI is already defined somewhere in the DOM, I
> suppose the registered prefix should be used instead.

That's fine in an XML (XHTML) document, but deserialization in an HTML
document will have different results (element svg with attribute xmlns
vs. element svg:svg with attribute xmlns:svg; both elements in the
HTML namespace and attributes with no namespace). Hence my question
;-)

My goal is not to have it defined in the spec, but at least to have it covered.

> > Also, should the "tag name" be lowercased before inclusion in the
> > output or the algorithm is just assuming the "tag name" of HTML
> > elements have already been lowercased elsewhere?
>
> I think that non-XHTML elements should stay "as entered".

Given that you serialize to non-XML, you'll need to parse with a
non-XML parser; and if you follow the rules for parsing HTML5,
everything will end up in the HTML namespace with lowercase name (and
this name will eventually include a colon). So it's really not
important what the spec says; but given that it says something, it
should be precise on what's intended…
My first reaction really was "heck, why is this something about
lowercasing here? given that it's dealt with, then how should I
understand it? I thought it had no importance, but if there's
something about it, then I guess it should have..."

-- 
Thomas Broyer


More information about the whatwg mailing list