Re: ISSUE-2273 (insertbefore_indexerr): Should negative index values raise INDEX_SIZE_ERR exceptions in insertItemBefore [SVG Full 1.1]

SVG Working Group Issue Tracker:
> ISSUE-2273 (insertbefore_indexerr): Should negative index values raise
> INDEX_SIZE_ERR exceptions in insertItemBefore [SVG Full 1.1]
…
> The SVG*List.insertItemBefore method doesn't raise an exception if
> the index parameter is negative, unlike the getItem and replaceItem
> methods.

The parameter for all of these methods is an unsigned long.  It’s not
normal to define behaviour (such as throwing an exception) at the IDL
level for values that don’t match the defined type.

Implementation of DOM methods typically do ToUint32() on an unsigned
long parameter, and that is what Web IDL defines.  If you passed in -1
that would mean it gets 2**32 - 1.  The definition for insertItemBefore
says:

  If the index is greater than or equal to numberOfItems, then the new
  item is appended to the end of the list.

so passing in -1 would result in the item being appended to the end of
the list.

If we actually want to make passing in a negative Number in the
ECMAScript binding result in an exception being thrown, then we should
state that (in a language binding specific manner), OR make the
parameter a signed long so that we can define what happens when a
negative number is passed in at the IDL level.


I’d be interested to know what implementations do currently.

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Thursday, 21 May 2009 00:27:44 UTC