Skip to content

Commit

Permalink
fix: allow multiline expression in v-for
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and hefeng committed Jan 25, 2019
1 parent 61567d9 commit 8e4d75a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/parser/index.js
Expand Up @@ -21,7 +21,7 @@ import {

export const onRE = /^@|^v-on:/
export const dirRE = /^v-|^@|^:/
export const forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/
export const forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/
export const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/
const stripParensRE = /^\(|\)$/g

Expand Down
20 changes: 20 additions & 0 deletions test/unit/features/directives/for.spec.js
Expand Up @@ -464,6 +464,26 @@ describe('Directive v-for', () => {
}).then(done)
})

// #7792
it('should work with multiline expressions', () => {
const vm = new Vue({
data: {
a: [1],
b: [2]
},
template: `
<div>
<span v-for="n in (
a.concat(
b
)
)">{{ n }}</span>
</div>
`
}).$mount()
expect(vm.$el.textContent).toBe('12')
})

const supportsDestructuring = (() => {
try {
new Function('var { foo } = bar')
Expand Down

0 comments on commit 8e4d75a

Please sign in to comment.