W3C home > Mailing lists > Public > public-webapi@w3.org > May 2006

Creating DOM Ranges when node is not in document

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Tue, 16 May 2006 16:57:00 +0300
Message-ID: <4469DA2C.1060800@helsinki.fi>
To: "Web APIs WG (public)" <public-webapi@w3.org>, www-dom@w3.org

Hi,

I wonder if there will be any DOM 2 Ranges errata, which would
clarify some problems in that specification.

For example what should happen in this case
javascript:var r = document.createRange(); 
r.setStart(document.createElement("foo"), 0);

Some implementations allow creating a range even if the
boundary node isn't in the document, some implementations
thrown an exception.

http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/ranges.html#Level-2-Range-Position
"The boundary-points of a Range _must_ have a common ancestor container 
which is either a Document, DocumentFragment or Attr node. That is, the 
content of a Range must be entirely within the subtree rooted by a 
single Document, DocumentFragment or Attr Node."

But Range.setStart Exceptions
INVALID_NODE_TYPE_ERR: Raised if refNode or an ancestor of refNode is an
                        Entity, Notation, or DocumentType node.

INDEX_SIZE_ERR:        Raised if offset is negative or greater than the 

                        number of child units in refNode. Child units are
                        16-bit units if refNode is a type of
                        CharacterData node (e.g., a Text
                        or Comment node) or a ProcessingInstruction node.
                        Child units are Nodes in all other cases.

INVALID_STATE_ERR:     Raised if detach() has already been invoked on
                        this object.


br,

-Olli
Received on Tuesday, 16 May 2006 13:57:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:55 GMT