Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3017 closed defect (invalid)

ShrinkSafe / Rhino does not support object literals named "class"

Reported by: guest Owned by: anonymous
Priority: high Milestone:
Component: General Version: 0.4.2
Keywords: Cc:
Blocked By: Blocking:

Description

Hello,

"""

cat testjs.js

var v = {class: "foo"};

java -jar custom_rhino.jar testjs.js

js: "testjs.js", line 1: l'identifiant de propriÚtÚ est incorrect js: var v = {class: "foo"}; js: .............. js: "testjs.js", line 1: Compilation produced 1 syntax errors. """

The error being "invalid property identifier".

This is probably a Rhino issue but you will probably handle it better than I could. I have seen nothing about that in Rhino bug tracker. Or maybe, "class" property is actually forbidden in Javascript...

-- pmezard /at/ gmail /dot/ com

Change History (2)

comment:1 Changed 13 years ago by dylan

Resolution: invalid
Status: newclosed

class is a reserved word in JavaScript?. If you do the following, it will work:

var v = {"class": "foo"};

though that might not be ideal for you, because then you would always have to use vclass? syntax instead of v.class.

comment:2 Changed 13 years ago by dylan

note that was

v["class"]
Note: See TracTickets for help on using tickets.