Skip to content

Commit

Permalink
We no longer need to wrap in quotes JavaScript reserved words used as…
Browse files Browse the repository at this point in the history
… properties (#4527)
  • Loading branch information
GeoffreyBooth authored Apr 24, 2017
1 parent 5651b8b commit 7e35c2c
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 54 deletions.
2 changes: 1 addition & 1 deletion lib/coffeescript/browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/cake.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/coffeescript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions lib/coffeescript/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 24 additions & 31 deletions lib/coffeescript/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/coffeescript/optparse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/repl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,7 @@ exports.Access = class Access extends Base
name = @name.compileToFragments o
node = @name.unwrap()
if node instanceof PropertyName
if node.value in JS_FORBIDDEN
[@makeCode('["'), name..., @makeCode('"]')]
else
[@makeCode('.'), name...]
[@makeCode('.'), name...]
else
[@makeCode('['), name..., @makeCode(']')]

Expand Down Expand Up @@ -1781,9 +1778,6 @@ exports.Assign = class Assign extends Base
if @variable.shouldCache()
compiledName.unshift @makeCode '['
compiledName.push @makeCode ']'
else if fragmentsToText(compiledName) in JS_FORBIDDEN
compiledName.unshift @makeCode '"'
compiledName.push @makeCode '"'
return compiledName.concat @makeCode(": "), val

answer = compiledName.concat @makeCode(" #{ @context or '=' } "), val
Expand Down
2 changes: 1 addition & 1 deletion test/modules.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ test "#4451: `default` in an export statement is only treated as a keyword when
input = "export default { default: 1 }"
output = """
export default {
"default": 1
default: 1
};
"""
eq toJS(input), output
Expand Down

0 comments on commit 7e35c2c

Please sign in to comment.