- From: Frans Englich <frans.englich@telia.com>
- Date: Fri, 22 Dec 2006 12:37:12 +0100
- To: www-dom@w3.org
Hi everyone, Me and my co-developer were discussing how attributes are to be treated within DOM. For interface Attr, this paragraph can be found: "Attr objects inherit the Node interface, but since they are not actually child nodes of the element they describe, the DOM does not consider them part of the document tree. Thus, the Node attributes parentNode, previousSibling, and nextSibling have a null value for Attr objects. " So, now one can start thinking about what an implementation is supposed to do: * "they are not actually child nodes of the element" but Node.appendChild(attr) is nevertheless supposed to work. However, it doesn't populate childNodes(), but instead adds the attribute to the imaginary Node.attributes() list. * appendChild() always raise an exception when being passed an attribute because "they are not actually child nodes of the element". The only way to add an Attr node to an element is to use Element::setAttributeNode(). Which one to choose? Or perhaps a third alternative? Clarifications, such as pointers to the spec, are appreciated. If there's any distinction on this topic between Level 2 and 3, it would be great if they are pointed out. Thanks in advance, Frans
Received on Friday, 22 December 2006 11:36:03 UTC