W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2015

[Bug 28875] [EnforceRange] accepts an odd set of input values

From: <bugzilla@jessica.w3.org>
Date: Wed, 01 Jul 2015 23:04:29 +0000
To: public-script-coord@w3.org
Message-ID: <bug-28875-3890-cD5djwY0A9@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28875

--- Comment #4 from Jeffrey Yasskin <jyasskin@gmail.com> ---
[EnforceRange] already works around a quirk of Javascript in a random set of
(not primarily DOM) APIs. If it's going to exist at all, it may as well work
around the quirk well.

Most APIs that take integer types uniformly treat all of {}, [], undefined,
null, and NaN as 0. Only APIs that try to enforce an integral range pick an
arbitrary subset of those to throw an exception on.

array.length is a good precedent for how to enforce ranges, but
http://ecma-international.org/ecma-262/6.0/#sec-arraysetlength already behaves
differently from [EnforceRange]. It checks that ToNumber(arg) and ToUint32(arg)
give the same result, which throws a TypeError on "x.length = 3.2".
enforceRange(3.2) returns 3. Maybe we should just unify those behaviors and
call it a day? It wouldn't be quite the ideal behavior, but it'd be
consistently odd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Received on Wednesday, 1 July 2015 23:04:31 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 1 July 2015 23:04:31 UTC