DOM Range setStart and setEnd exceptions

The setEndAfter, setEndBefore, setStartAfter and setStartBefore methods
on the Range interface (defined in the DOM2 Traversal and Range
specification) can raise INVALID_NODE_TYPE_ERR if the root container of
refNode is not an Attr, Document or DocumentFragment node.  The
specification states that "the content of a Range must be entirely
within the subtree rooted by a single Document, DocumentFragment or Attr
Node", so these exceptions make sense.

The setStart and setEnd methods don't seem to throw an exception if this
happens.  Opera does throw an exception here, but other browsers do not.
 Should an exception be thrown?

I think an exception should be thrown to preserve the invariants given
in the spec.

-- 
Andrew Oakley

Received on Thursday, 13 May 2010 10:26:52 UTC