Skip to content

Commit f96075d

Browse files
committed
Merge pull request vuejs#719 from calebboyd/devb
fix vuejs#717: support multiline expressions
2 parents 9704154 + 8de1bb8 commit f96075d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ test/unit/specs.js
33
explorations
44
node_modules
55
.DS_Store
6+
.idea
67
benchmarks/browser.js
78
coverage

src/parsers/expression.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var keywords =
1616

1717
var wsRE = /\s/g
1818
var newlineRE = /\n/g
19-
var saveRE = /[\{,]\s*[\w\$_]+\s*:|'[^']*'|"[^"]*"/g
19+
var saveRE = /[\{,]\s*[\w\$_]+\s*:|('[^']*'|"[^"]*")/g
2020
var restoreRE = /"(\d+)"/g
2121
var pathTestRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\])*$/
2222
var pathReplaceRE = /[^\w$\.]([A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\])*)/g
@@ -38,12 +38,15 @@ var saved = []
3838
* Save replacer
3939
*
4040
* @param {String} str
41+
* @param {String} isString - str if matched as a string
4142
* @return {String} - placeholder with index
4243
*/
4344

44-
function save (str) {
45+
function save (str, isString) {
4546
var i = saved.length
46-
saved[i] = str.replace(newlineRE, '\\n')
47+
saved[i] = isString
48+
? str.replace(newlineRE, '\\n')
49+
: str.replace(wsRE,'')
4750
return '"' + i + '"'
4851
}
4952

test/unit/specs/parsers/expression_spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ var testCases = [
6262
expected: 'inline hel\nlo',
6363
paths: ['a']
6464
},
65+
{
66+
//multiline expressions
67+
exp: "{\n a: '35',\n b: c}",
68+
scope:{c:32},
69+
expected: { a : '35', b : 32 }
70+
},
6571
{
6672
// dollar signs and underscore
6773
exp: "_a + ' ' + $b",

0 commit comments

Comments
 (0)