8000 fix #242 expressions with object literals · terrierscript/vue@e422d95 · GitHub
[go: up one dir, main page]

Skip to content

Commit e422d95

Browse files
author
Evan You
committed
fix vuejs#242 expressions with object literals
1 parent bab4829 commit e422d95

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/exp-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var KEYWORDS =
2323
',Math',
2424

2525
KEYWORDS_RE = new RegExp(["\\b" + KEYWORDS.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g'),
26-
REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,
26+
REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+|[\{,]\s*[\w\$_]+\s*:/g,
2727
SPLIT_RE = /[^\w$]+/g,
2828
NUMBER_RE = /\b\d[^,]*/g,
2929
BOUNDARY_RE = /^,+|,+$/g

test/unit/specs/exp-parser.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ describe('Expression Parser', function () {
8282
hi: 2
8383
},
8484
expectedValue: '"test"1\'hi\'2'
85+
},
86+
{
87+
// expressions with inline object literals
88+
exp: "sortRows({ column: 'name', test: 'haha', durrr: 123 })",
89+
vm: {
90+
sortRows: function (params) {
91+
return params.column + params.durrr
92+
}
93+
},
94+
expectedValue: 'name123'
8595
}
8696
]
8797

0 commit comments

Comments
 (0)
0