- From: Jonas Sicking <jonas@sicking.cc>
- Date: Fri, 9 Sep 2011 10:28:51 -0700
- To: David Flanagan <dflanagan@mozilla.com>, Cameron McCormack <cam@mcc.id.au>
- Cc: public-script-coord@w3.org
On Fri, Sep 9, 2011 at 9:43 AM, David Flanagan <dflanagan@mozilla.com> wrote: > WebIDL has just introduced an [EnforceRange] attribute that alters the > behavior of numeric conversions. I argued for something like this using > CharacterData.deleteData() as an example. In DOM Level 2, it was specified > to throw a TypeError for negative arguments, even though those arguments > were unsigned long and WebIDL would automatically convert any negative > arguments to positive. > > The last time I checked, the Webkit browsers do throw TypeError for negative > arguments (following DOM 2) and Firefox converts -1 to the maximum positive > unsigned long value (following the current version of DOM4). > > I'd like to suggest that the arguments to this (and similar) methods be > declared with [EnforceRange], which would bring DOM4 back into alignment > with the intent of DOM Level 2. If someone passes -1 to deleteData(), I > think it is safe to say that they don't really mean 2^32-1. An error is the > right thing here. I really think that we should not default to the wrapping behavior. I strongly doubt that's commonly what people want. And I also suspect that in the vast majority of cases it would be web compatible as well as a usability improvement to make negative values throw. *If* there are cases where this wouldn't be web compatible, I propose we make those functions take signed values and describe the wrapping in prose, I'd be surprised if this will be needed in more than one or two locations, if at all. In the IndexedDB spec we've started working around the current default behavior for unsigned arguments by making arguments signed and define that an exception is thrown for negative values. This is strictly making the spec harder to read. / Jonas
Received on Friday, 9 September 2011 17:29:56 UTC