W3C home > Mailing lists > Public > public-html@w3.org > January 2009

Re: Placing elements in the HTML namespace

From: Maciej Stachowiak <mjs@apple.com>
Date: Thu, 15 Jan 2009 22:32:12 -0800
Cc: Boris Zbarsky <bzbarsky@mit.edu>, Anne van Kesteren <annevk@opera.com>, HTML WG <public-html@w3.org>
Message-id: <E6B8F35B-CD44-401E-ACFB-033709741C21@apple.com>
To: Jonas Sicking <jonas@sicking.cc>

On Jan 15, 2009, at 8:35 PM, Jonas Sicking wrote:

> On Thu, Jan 15, 2009 at 7:53 PM, Maciej Stachowiak <mjs@apple.com>  
> wrote:
>> On Jan 15, 2009, at 7:40 PM, Jonas Sicking wrote:
>>> Maciej Stachowiak wrote:
>>>> In WebKit we implement all HTML/XHTML differences based on  
>>>> whether the
>>>> containing document is an HTML or XML document. The element objects
>>>> themselves are indistinguishable.
>>> Wouldn't that mean that they change name when moved between  
>>> documents?
>>> From 'div' to 'DIV'?
>> Yes, Node.nodeName and Element.tagName would change from lowercase to
>> uppercase if the same element is moved from an XML document to an  
>> document. Node.localName would remain consistently lowercase.
> This seems a bit strange to me. It also seems strange that behavior of
> things like getElementsByTagName changes with the ownerDocument rather
> than being intrinsic to the node itself.

One could argue that this is strange. But one could equally argue that  
it's strange to allow the possibility of an element in an XML document  
having non-XML behavior, based not on the tag and namespace but only  
how the element happened to be created. Moving nodes between documents  
is fairly rare, so it probably doesn't matter that much, but this  
approach made the most sense to us.

I believe that  this behavior is also required by the current HTML5  
draft, since the special (case-insensitive or case-altering) behavior  
for certain DOM APIs is required for "HTML elements in HTML  
documents", and "does not apply to XML documents".

>> Note also that according to the spec the DOM elements cannot ever  
>> move
>> between documents, but browsers (including WebKit-based ones) do  
>> widely
>> allow this.
> That's not entirely true. Even DOM specs allow you to move a node
> between documents using adoptNode. There is also the importNode
> function, which doesn't move a node between documents, but is supposed
> to clone a node which is supposed to yield a node with the same name.

Fair enough, but the rare cases when this actually comes up in Web  
applications usually just insert the node rather than using adoptNode.

Received on Friday, 16 January 2009 06:32:56 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:41 UTC