diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/vModel.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/vModel.spec.ts.snap
index cdbe3c3eefa..bef1bd699b7 100644
--- a/packages/compiler-core/__tests__/transforms/__snapshots__/vModel.spec.ts.snap
+++ b/packages/compiler-core/__tests__/transforms/__snapshots__/vModel.spec.ts.snap
@@ -35,10 +35,14 @@ return function render(_ctx, _cache) {
return (_openBlock(), _createBlock(\\"input\\", {
modelValue:
- model
+ model
+.
+foo
,
\\"onUpdate:modelValue\\": $event => (
- model
+ model
+.
+foo
= $event)
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
}
diff --git a/packages/compiler-core/__tests__/transforms/vModel.spec.ts b/packages/compiler-core/__tests__/transforms/vModel.spec.ts
index 42f9c6052b2..119624cda8c 100644
--- a/packages/compiler-core/__tests__/transforms/vModel.spec.ts
+++ b/packages/compiler-core/__tests__/transforms/vModel.spec.ts
@@ -115,8 +115,9 @@ describe('compiler: transform v-model', () => {
expect(generate(root, { mode: 'module' }).code).toMatchSnapshot()
})
+ // #2426
test('simple expression (with multilines)', () => {
- const root = parseWithVModel('')
+ const root = parseWithVModel('')
const node = root.children[0] as ElementNode
const props = ((node.codegenNode as VNodeCall).props as ObjectExpression)
.properties
@@ -127,7 +128,7 @@ describe('compiler: transform v-model', () => {
isStatic: true
},
value: {
- content: '\n model \n',
+ content: '\n model\n.\nfoo \n',
isStatic: false
}
})
@@ -141,7 +142,7 @@ describe('compiler: transform v-model', () => {
children: [
'$event => (',
{
- content: '\n model \n',
+ content: '\n model\n.\nfoo \n',
isStatic: false
},
' = $event)'
diff --git a/packages/compiler-core/src/utils.ts b/packages/compiler-core/src/utils.ts
index efc97f5d4c4..107bb0f6c14 100644
--- a/packages/compiler-core/src/utils.ts
+++ b/packages/compiler-core/src/utils.ts
@@ -56,7 +56,7 @@ const nonIdentifierRE = /^\d|[^\$\w]/
export const isSimpleIdentifier = (name: string): boolean =>
!nonIdentifierRE.test(name)
-const memberExpRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[[^\]]+\])*$/
+const memberExpRE = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*|\[[^\]]+\])*$/
export const isMemberExpression = (path: string): boolean => {
if (!path) return false
return memberExpRE.test(path.trim())