Closed Bug 62613 Opened 24 years ago Closed 23 years ago

CSSStyleDeclaration doesn't support array access for item() method

Categories

(Core :: DOM: CSS Object Model, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.4

People

(Reporter: david, Assigned: jst)

Details

(Keywords: dom2, Whiteboard: [FIXED ON TRUNK], need a=?)

Attachments

(3 files)

The CSSStyleDeclaration interface has an item(int) method, which means
that CSSStyleDeclaration objects should behave like arrays.  But they don't, as
demonstrated by the following code:

<head>
<style>
P { color: red }
</style>
</head>
<body>
<script>
var rule = document.styleSheets[0].cssRules[0];
// Bug: this should display "P { color: red }"
document.write("<p>rule.cssText: " + rule.cssText);

// Bug: this should display "P"
document.write("<p>rule.selectorText: " + rule.selectorText);

// Bug: this should return "color: red"
document.write("<p>rule.style.cssText: " + rule.style.cssText);

// Bug: this should work like calling item()
document.write("<p>rule.style[0]: " + rule.style[0]);

document.write("<p>rule.style.item(0): " + rule.style.item(0));
</script>
</body>
See also bug #62607, bug #62611, bug #62612
Keywords: correctness
Thanks for the testcase, could you put that in a file and attach it to this bug,
that way it's even easier for me to work on this once I get to this.

This is not serious enough to get any attention for the next release tho so I'm
futuring this for now.
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → Future
Made the testcase into an attachment, per JST's request.

I don't know when the next release is scheduled for, so I won't disupute the
assertion that it isn't important enough.  However, at a minimum, I think that
the DOMImplementation class should be changed to stop reporting that it supports
the "CSS" feature, since this bug, along with 62607, 62611, and 62612 make it
seem kind of broken.  I'll submit a separate bug for that.
Keywords: dom2
Component: DOM Level 2 → DOM Style
Taking QA Contact on all open or unverified DOM Style bugs...
QA Contact: vidur → ian
Attached patch changes the scriptable flags for nsCSSStyleDeclSH from
DOM_DEFAULT_FLAGS to ARRAY_SCRIPTABLE_FLAGS and implements
nsCSSStyleDeclSH::GetProperty(). I didn't call the security manager because I
didn't see any compelling reason to do so for style sheets.
jst, your class info stuff RULES!
Keywords: patch, review
Whiteboard: [HAVE FIX]
Fabian, cool, but I think you went a bit too far here :-) You should only need
to change the flags, the rest should work as is.
LOL, I just copied the patch you did for nsHistorySH ;-)
New patch coming up.
I figured as much :-)
Attachment #47732 - Flags: needs-work+
Comment on attachment 47850 [details] [diff] [review]
Change DOM_DEFAULT_SCRIPTABLE_FLAGS to ARRAY_SCRIPTABLE_FLAGS

sr=jst
Attachment #47850 - Flags: superreview+
Pulling back to 0.9.4, there's absolutely no reason to not check this in.
Target Milestone: Future → mozilla0.9.4
Comment on attachment 47850 [details] [diff] [review]
Change DOM_DEFAULT_SCRIPTABLE_FLAGS to ARRAY_SCRIPTABLE_FLAGS

r=harishd
Attachment #47850 - Flags: review+
Whiteboard: [HAVE FIX] → [HAVE FIX], need a=?
Fix checked in on the trunk.
Whiteboard: [HAVE FIX], need a=? → [FIXED ON TRUNK], need a=?
Comment on attachment 47850 [details] [diff] [review]
Change DOM_DEFAULT_SCRIPTABLE_FLAGS to ARRAY_SCRIPTABLE_FLAGS

a=asa on behalf of drivers for checkin to the 0.9.4 branch.
Attachment #47850 - Flags: approval+
Fix checekd in on the branch too.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: