aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ng/parse.js8
-rw-r--r--test/ng/parseSpec.js5
2 files changed, 13 insertions, 0 deletions
diff --git a/src/ng/parse.js b/src/ng/parse.js
index bd3aa048..885dc50a 100644
--- a/src/ng/parse.js
+++ b/src/ng/parse.js
@@ -785,6 +785,10 @@ Parser.prototype = {
var allConstant = true;
if (this.peekToken().text !== ']') {
do {
+ if (this.peek(']')) {
+ // Support trailing commas per ES5.1.
+ break;
+ }
var elementFn = this.expression();
elementFns.push(elementFn);
if (!elementFn.constant) {
@@ -811,6 +815,10 @@ Parser.prototype = {
var allConstant = true;
if (this.peekToken().text !== '}') {
do {
+ if (this.peek('}')) {
+ // Support trailing commas per ES5.1.
+ break;
+ }
var token = this.expect(),
key = token.string || token.text;
this.consume(':');
diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js
index 466be755..38fce3f7 100644
--- a/test/ng/parseSpec.js
+++ b/test/ng/parseSpec.js
@@ -460,6 +460,8 @@ describe('parser', function() {
expect(scope.$eval("[1, 2]").length).toEqual(2);
expect(scope.$eval("[1, 2]")[0]).toEqual(1);
expect(scope.$eval("[1, 2]")[1]).toEqual(2);
+ expect(scope.$eval("[1, 2,]")[1]).toEqual(2);
+ expect(scope.$eval("[1, 2,]").length).toEqual(2);
});
it('should evaluate array access', function() {
@@ -474,6 +476,9 @@ describe('parser', function() {
expect(toJson(scope.$eval("{a:'b'}"))).toEqual('{"a":"b"}');
expect(toJson(scope.$eval("{'a':'b'}"))).toEqual('{"a":"b"}');
expect(toJson(scope.$eval("{\"a\":'b'}"))).toEqual('{"a":"b"}');
+ expect(toJson(scope.$eval("{a:'b',}"))).toEqual('{"a":"b"}');
+ expect(toJson(scope.$eval("{'a':'b',}"))).toEqual('{"a":"b"}');
+ expect(toJson(scope.$eval("{\"a\":'b',}"))).toEqual('{"a":"b"}');
});
it('should evaluate object access', function() {