- From: Christopher Aillon <caillon@returnzero.com>
- Date: Thu, 31 Oct 2002 16:48:53 -0500 (EST)
- To: www-dom@w3.org
I am the original implementor of (the since renamed) compareTreePosition in Mozilla. I'm interested in updating our implementation to the latest draft, but have a few issues with the way the 20021022 draft is defined. First, the following constants (among others) are defined on the Node interface: const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x00; const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x10; And, Definition group DocumentPosition says: If the two nodes being compared are the same node, then no flags are set on the return. If I were using the JavaScript language (as all my examples will use), it would then follow that: var flags = foo.compareDocumentPosition(foo); flags == 0; // true flags == Node.DOCUMENT_POSITION_DISCONNECTED; // true!?!? Clearly, this seems to be a problem. If the SAME_NODE bit has been removed, then that is fine, but two identical nodes should not be disconnected. Further on in the Definition group DocumentPosition: If there is no common container node, then the order is based upon order between the root container of each node that is in no container. In this case, the result is disconnected and implementation-dependent. This result is stable as long as these outer-most containing nodes remain in memory and are not inserted into some other containing node. This would be the case when the nodes belong to different documents or fragments, and cloning the document or inserting a fragment might change the order. So, with another example, if I have two nodes foo and bar which are in different documents: var flags = foo.compareDocumentPosition(bar); flags & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; // true flags & 0; // false flags & Node.DOCUMENT_POSITION_DISCONNECTED; // false!?!? In general, I do like the way the WD is going with the updated version of compareDocumentPosition. However, unless I misunderstood the latest WD, by removing the SAME_NODE constant and by allowing disconnected nodes to have other bits set, it appears there is a need to give disconnected its own bit, instead of none. That would solve both of the issues I raised. Comments? -- Christopher
Received on Thursday, 31 October 2002 17:57:01 UTC