Skip to content

Commit

Permalink
fix: allow multiline expression in v-for
Browse files Browse the repository at this point in the history
fix #7792
  • Loading branch information
yyx990803 committed Mar 11, 2018
1 parent af5453c commit 71b4b25
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

1 comment on commit 71b4b25

@shizhenbin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

Please sign in to comment.