Bug 12527

Summary: "class" doesn't work as a JS var
Product: WebKit Reporter: Darin Fisher (:fishd, Google) <fishd>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: ap, barraclough, WebKitBugzilla
Priority: P2    
Version: 420+   
Hardware: All   
OS: All   
Attachments:
Description Flags
testcase none

Description Darin Fisher (:fishd, Google) 2007-02-01 00:50:14 PST
class selector doesn't work dynamically

testcase coming up...
Comment 1 Darin Fisher (:fishd, Google) 2007-02-01 00:52:30 PST
Created attachment 12851 [details]
testcase
Comment 2 Dave Hyatt 2007-02-01 02:28:43 PST
This actually has nothing to do with CSS, which works fine.  The issue is with JavaScript, which is not allowing the use of the word "class" as a variable name.  The JS console reports a parse error on that line.

Comment 3 Alexey Proskuryakov 2007-02-01 06:46:29 PST

*** This bug has been marked as a duplicate of 6179 ***
Comment 4 Darin Adler 2007-02-01 10:15:26 PST
How can this be a duplicate of a bug that's fixed?

I guess the issue here is that class works in Firefox, but not Windows IE.
Comment 5 Maciej Stachowiak 2007-02-01 11:11:16 PST
Yes, it's not a duplicate. We might not want to fix it though, since IE still treats "class" as a future keyword.
Comment 6 Geoffrey Garen 2007-02-01 12:27:05 PST
In bug 6179, I chose to follow WinIE rather than Mozilla, and reserve 'class'. Is there a compelling real-world example that justifies unreserving 'class'?
Comment 7 Alexey Proskuryakov 2007-02-01 12:30:36 PST
(In reply to comment #4)
> How can this be a duplicate of a bug that's fixed?

This was the original issue reported in bug 6179, but the bug was re-purposed after it was decided that it was invalid. Since bug 6179 contains the rationale for our behavior in this case, I marked this as a duplicate.
Comment 8 Darin Fisher (:fishd, Google) 2007-03-17 12:23:48 PDT
so, should this be closed as WONTFIX then?
Comment 9 Timothy Churchward 2008-11-02 17:25:27 PST
Personally I'm fine with being stricter with the "class" keyword ... but I can definitely see the argument for not allowing it.

However, maybe instead of a Parse Error it should be a console warning?

Furthermore, in using the new Debug Inspector if a JavaScript contains the someObject.class or var class WebKit seems to crash after a few seconds.
Comment 10 Alexey Proskuryakov 2008-11-03 01:19:51 PST
(In reply to comment #9)
> Furthermore, in using the new Debug Inspector if a JavaScript contains the
> someObject.class or var class WebKit seems to crash after a few seconds.

Could you please file a new bug for this?
Comment 11 Timothy Churchward 2008-11-04 20:54:30 PST
(In reply to comment #10)
> Could you please file a new bug for this?

Good call, please see https://bugs.webkit.org/show_bug.cgi?id=22046
Comment 12 Gavin Barraclough 2011-06-15 00:03:36 PDT
Per the ES5 spec, class is not a reserved word.  This is definitely now correct behaviour.