mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 03:21:20 -05:00
adding paren wrappers for property accesses directly on object literals
This commit is contained in:
@@ -320,6 +320,9 @@
|
|||||||
only = del(o, 'only_first');
|
only = del(o, 'only_first');
|
||||||
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
|
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
|
||||||
baseline = this.base.compile(o);
|
baseline = this.base.compile(o);
|
||||||
|
if (this.base instanceof ObjectNode && this.has_properties()) {
|
||||||
|
baseline = '(' + baseline + ')';
|
||||||
|
}
|
||||||
parts = [baseline];
|
parts = [baseline];
|
||||||
__a = props;
|
__a = props;
|
||||||
for (__b = 0; __b < __a.length; __b++) {
|
for (__b = 0; __b < __a.length; __b++) {
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ ValueNode: exports.ValueNode: inherit Node, {
|
|||||||
only: del(o, 'only_first')
|
only: del(o, 'only_first')
|
||||||
props: if only then @properties[0...@properties.length - 1] else @properties
|
props: if only then @properties[0...@properties.length - 1] else @properties
|
||||||
baseline: @base.compile o
|
baseline: @base.compile o
|
||||||
|
baseline: '(' + baseline + ')' if @base instanceof ObjectNode and @has_properties()
|
||||||
parts: [baseline]
|
parts: [baseline]
|
||||||
|
|
||||||
for prop in props
|
for prop in props
|
||||||
|
|||||||
3
test/fixtures/execution/test_literals.coffee
vendored
3
test/fixtures/execution/test_literals.coffee
vendored
@@ -37,6 +37,9 @@ money$: 'dollars'
|
|||||||
puts money$ is 'dollars'
|
puts money$ is 'dollars'
|
||||||
|
|
||||||
|
|
||||||
|
puts {a: (num) -> num is 10 }.a 10
|
||||||
|
|
||||||
|
|
||||||
bob: {
|
bob: {
|
||||||
name: 'Bob'
|
name: 'Bob'
|
||||||
greet: (salutation) ->
|
greet: (salutation) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user