This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11749 - Do we really want values to wrap instead of clamping?
Summary: Do we really want values to wrap instead of clamping?
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-13 19:55 UTC by Aryeh Gregor
Modified: 2011-05-24 22:26 UTC (History)
4 users (show)

See Also:


Attachments

Description Aryeh Gregor 2011-01-13 19:55:45 UTC
The algorithm to convert ECMAScript values to various IDL types (octet, short, etc.) specifies that they wrap if they're out of range, by saying that they're taken mod 2^8 or 2^16 or whatever.  Is this behavior really necessary?  Clamping to the nearest allowed value is much nicer behavior, if it's compatible with how browsers behave.
Comment 1 Boris Zbarsky 2011-01-13 20:57:13 UTC
Is it compatible?

(Note that generally wrapping is faster to do, so unless there's a good reason to expect that people will need to rely on the clamping it's easier to not support it.)
Comment 2 Cameron McCormack 2011-05-24 22:26:15 UTC
I don't know about compatibility with content.  I'm inclined to leave it as is, for the reason Boris states, and that the wrapping is what the ES5 spec uses when builtin functions need to convert a value to an integer.

FWIW,

data:text/html,<script>a=document.createElement("input");a.size=4294967297;alert(a.size)</script>

alerts "1" (4294967297 being 2^32+1) in Firefox, Safari, Chrome and IE.  In Opera it alerts "-2147483648"