mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
be more flexible about trailing commas in implicit object literals.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -134,9 +134,9 @@
|
||||
before = this.tokens[i - 2];
|
||||
after = this.tokens[i + 2];
|
||||
open = stack[len] > 0;
|
||||
if ((tag === 'TERMINATOR' && !((after && after[0] === ':') || (post && post[0] === '@' && this.tokens[i + 3] && this.tokens[i + 3][0] === ':'))) || (running && tag === ',' && post && (!('IDENTIFIER' === (_c = post[0]) || 'STRING' === _c || '@' === _c)))) {
|
||||
if ((tag === 'TERMINATOR' && !((after && after[0] === ':') || (post && post[0] === '@' && this.tokens[i + 3] && this.tokens[i + 3][0] === ':'))) || (running && tag === ',' && post && (!('IDENTIFIER' === (_c = post[0]) || 'STRING' === _c || '@' === _c || 'TERMINATOR' === _c)))) {
|
||||
running = false;
|
||||
return closeBrackets(i);
|
||||
return closeBrackets(post && post[0] === 'OUTDENT' ? i + 1 : i);
|
||||
} else if (include(EXPRESSION_START, tag)) {
|
||||
stack.push(tag === '{' ? 1 : 0);
|
||||
if (tag === '{' && post && post[0] === 'INDENT') {
|
||||
|
||||
@@ -133,9 +133,9 @@ exports.Rewriter = class Rewriter
|
||||
after = @tokens[i + 2]
|
||||
open = stack[len] > 0
|
||||
if (tag is 'TERMINATOR' and not ((after and after[0] is ':') or (post and post[0] is '@' and @tokens[i + 3] and @tokens[i + 3][0] is ':'))) or
|
||||
(running and tag is ',' and post and (post[0] not in ['IDENTIFIER', 'STRING', '@']))
|
||||
(running and tag is ',' and post and (post[0] not in ['IDENTIFIER', 'STRING', '@', 'TERMINATOR']))
|
||||
running = no
|
||||
return closeBrackets(i)
|
||||
return closeBrackets(if post and post[0] is 'OUTDENT' then i + 1 else i)
|
||||
else if include EXPRESSION_START, tag
|
||||
stack.push(if tag is '{' then 1 else 0)
|
||||
return 2 if tag is '{' and post and post[0] is 'INDENT'
|
||||
|
||||
@@ -140,6 +140,13 @@ obj =
|
||||
ok obj.a is 1
|
||||
ok obj.b is 2
|
||||
|
||||
obj =
|
||||
a: 1,
|
||||
b: 2,
|
||||
|
||||
ok obj.a is 1
|
||||
ok obj.b is 2
|
||||
|
||||
|
||||
# Implicit objects nesting.
|
||||
obj =
|
||||
|
||||
Reference in New Issue
Block a user