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 aJean committed Aug 19, 2020
1 parent 75b57d8 commit e54df9f
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 e54df9f

Please sign in to comment.