W3C home > Mailing lists > Public > www-svg@w3.org > November 2001

How should negative numbers be handled in insertItemBefore method??

From: Robert Diblasi <rdiblas@wpo.it.luc.edu>
Date: Mon, 12 Nov 2001 20:26:02 -0600
Message-Id: <sbf0305f.048@wpo.it.luc.edu>
To: <www-svg@w3.org>
Hello,

  I would like to propose a change for 1.0,1.1,2.0,moble

If you read insertItemBefore method in any of the list conditions
in SVG that use insertItemBefore....they do not cover all the conditions
....they do not explain how a implementation should handle a negative number.

I believe that this is all the interfaces that have isertItemBefore:

SVGLengthList
SVGNumberList
SVGStringList 

Here is the method definition:
<snip>
insertItemBefore 
Inserts a new item into the list at the specified position. 
The first item is number 0. 
If newItem is already in a list, it is removed from its previous 
list before it is inserted into this list. 


Parameters 
in DOMString newItem   The item which is to be inserted into the list.  
in unsigned long index   The index of the item before which the new item 
is to be inserted. 
The first item is number 0.
If the index is equal to 0, then the new item is inserted at the 
front of the list. If the index is greater than or equal to numberOfItems,
then the new item is appended to the end of the list.  

Return value 
DOMString   The inserted item.  

Exceptions 
DOMException   NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.  
SVGException   SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong 
               type of object for the given list. 
</snip>

I would like to  propose a review of the "index" parameter of insertItemBefore method.

insertItemBefore does not define whether a negative number used in the 
index parameter is an error condition or is allowed.

If allowed...I would like to modify the explanation of index to:

(revised suggestion)
in unsigned long index   The index of the item before which the new item 
is to be inserted. The first item is number 0.
If the index is less then or equal to 0, then the new item is inserted at the 
front of the list. If the index is greater than or equal to numberOfItems,
 then the new item is appended to the end of the list.  

Notice that the this modified definition takes into account negative numbers
by placing them at the beginning of the list


if an error...I would like to see the specification point this out

We all learn by sharing what we know
Robert A. DiBlasi
Received on Monday, 12 November 2001 21:26:30 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:21 GMT