From e3a6c6648255d49ef1895486c5ae5fe3c428360b Mon Sep 17 00:00:00 2001 From: shasharoman Date: Thu, 28 Mar 2019 21:56:41 +0800 Subject: [PATCH 1/3] fix(#9781): fixed `dynamicArgAttribute` RegExp --- src/compiler/parser/html-parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser/html-parser.js b/src/compiler/parser/html-parser.js index dbc59146331..37c1fa24d58 100644 --- a/src/compiler/parser/html-parser.js +++ b/src/compiler/parser/html-parser.js @@ -15,7 +15,7 @@ import { unicodeRegExp } from 'core/util/lang' // Regular Expressions for parsing tags and attributes const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ -const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ +const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*` const qnameCapture = `((?:${ncname}\\:)?${ncname})` const startTagOpen = new RegExp(`^<${qnameCapture}`) From d2c044661367433e383d41e3eab0898655cd0c49 Mon Sep 17 00:00:00 2001 From: shasharoman Date: Fri, 29 Mar 2019 23:59:25 +0800 Subject: [PATCH 2/3] test(parser): add test case for multiple dynamic slot names --- test/unit/modules/compiler/parser.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index d6521bbf625..60515767dc1 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -569,6 +569,22 @@ describe('parser', () => { }) }) + // #9781 + it('multiple dynamic slot names without warning', () => { + const ast = parse(` + + + `, baseOptions) + + expect(`Invalid dynamic argument expression`).not.toHaveBeenWarned() + expect(ast.scopedSlots.foo).not.toBeUndefined() + expect(ast.scopedSlots.bar).not.toBeUndefined() + expect(ast.scopedSlots.foo.type).toBe(1) + expect(ast.scopedSlots.bar.type).toBe(1) + expect(ast.scopedSlots.foo.attrsMap['#[foo]']).toBe('') + expect(ast.scopedSlots.bar.attrsMap['#[bar]']).toBe('') + }) + // #6887 it('special case static attribute that must be props', () => { const ast = parse('', baseOptions) From 4b1f07dc8d108dd8f1b51c816b18ce2ab29fdb19 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 21 Sep 2020 12:31:54 +0200 Subject: [PATCH 3/3] test: add test with value --- test/unit/modules/compiler/parser.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index 60515767dc1..360bc11bbb6 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -573,16 +573,20 @@ describe('parser', () => { it('multiple dynamic slot names without warning', () => { const ast = parse(` + - `, baseOptions) + `, baseOptions) expect(`Invalid dynamic argument expression`).not.toHaveBeenWarned() expect(ast.scopedSlots.foo).not.toBeUndefined() + expect(ast.scopedSlots.data).not.toBeUndefined() expect(ast.scopedSlots.bar).not.toBeUndefined() expect(ast.scopedSlots.foo.type).toBe(1) + expect(ast.scopedSlots.data.type).toBe(1) expect(ast.scopedSlots.bar.type).toBe(1) expect(ast.scopedSlots.foo.attrsMap['#[foo]']).toBe('') expect(ast.scopedSlots.bar.attrsMap['#[bar]']).toBe('') + expect(ast.scopedSlots.data.attrsMap['#[data]']).toBe('scope') }) // #6887