Re: range insertNode, what exception should be thrown?

On Wed, 30 May 2001, Dylan Schiemann wrote:
>
> Consider the following JavaScript syntax:
>
> var x = document.createRange();
> x.setStart(document.getElementsByTagName("p")[0],0);
> x.setEnd(document.getElementsByTagName("p")[0],1);
> x.insertNode(document.getElementsByTagName("div")[0]);
>
> Suppose that the document does not contain any div
> elements.  What exception should be thrown?

Typically, that kind of construct would raise a binding-specific
array-index-out-of-range exception. JavaScript just returns 'undefined' on
an out of range array lookup, so the exception that would be raised is
that same as that which would be raised by

   x.insertNode(null);

...which, per the DOM Core spec, is an implementation-specific exception:

# Implementations should raise other exceptions under other circumstances.
# For example, implementations should raise an implementation-dependent
# exception if a null argument is passed.
  -- http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-17189187
     paragraph 2

HTH,
-- 
Ian Hickson                                            )\     _. - ._.)   fL
Invited Expert, CSS Working Group                     /. `- '  (  `--'
The views expressed in this message are strictly      `- , ) -  > ) \
personal and not those of Netscape or Mozilla. ________ (.' \) (.' -' ______

Received on Wednesday, 30 May 2001 17:50:54 UTC