W3C home > Mailing lists > Public > public-svg-wg@w3.org > April to June 2009

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

From: Cameron McCormack <cam@mcc.id.au>
Date: Thu, 21 May 2009 10:26:56 +1000
To: public-svg-wg@w3.org
Message-ID: <20090521002656.GB16715@arc.mcc.id.au>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 21 May 2009 00:27:45 GMT