diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index ba1b726870..a603b36bb5 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -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 diff --git a/test/unit/features/directives/for.spec.js b/test/unit/features/directives/for.spec.js index ec270ca9cc..22528be62f 100644 --- a/test/unit/features/directives/for.spec.js +++ b/test/unit/features/directives/for.spec.js @@ -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: ` +
+ {{ n }} +
+ ` + }).$mount() + expect(vm.$el.textContent).toBe('12') + }) + const supportsDestructuring = (() => { try { new Function('var { foo } = bar')