document.styleSheets.item(String) should thrown an exception

RESOLVED INVALID

Status

()

Core
DOM: CSS Object Model
RESOLVED INVALID
15 years ago
5 years ago

People

(Reporter: Vladimir Ermakov, Unassigned)

Tracking

Trunk
Future
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

15 years ago
if you try to access document.styleSheets.item() with some string as a parameter
it returns the first style sheet. It should be throwing an exception
(Reporter)

Comment 1

15 years ago
Created attachment 112786 [details]
testcase
hmm.... document.styleSheets.item(0) and document.styleSheet.item("heh") should
be equivalent -- the "heh" is cast to a number by the JS engine and its numeric
value is 0.

Not sure what Infinity and NaN are doing...

Comment 3

15 years ago
In JavaScript, if the string 'hah' is coerced to a Number,
then NaN is the result:

js> Number('hah');
NaN

Whereas the empty string, or whitespace characters, get coerced to 0:

js> Number('');
0
js> Number('\n');
0
js> Number('\t');
0


Details: Section 9.3.1, "ToNumber Applied to the String Type"
ECMA-262 Edition 3 Final, http://www.mozilla.org/js/language
So the question then is what NaN and Infinity get coerced to when passed through
XPConnect as an unsigned int....

Comment 5

15 years ago
XPConnect uses JS_ValueToECMAUint32. So what ever that API does for that
conversion, so will XPConnect, including failing if the function returns false.
The key is probably here: http://lxr.mozilla.org/seamonkey/source/js/src/jsnum.c#703

Updated

15 years ago
Target Milestone: --- → Future
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
Assignee: general → nobody
QA Contact: ian → general
QA Contact: general → style-system
Web IDL says that "foo", NaN and Infinity all get converted to 0 when the type is "unsigned long" as it is for document.styleSheets.item().
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → WONTFIX

Updated

5 years ago
Resolution: WONTFIX → INVALID
You need to log in before you can comment on or make changes to this bug.