From 2ee2fddea27b3829d8872e19855a7e6699e0b652 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com> Date: Fri, 3 Sep 2021 16:02:15 +0800 Subject: [PATCH] fix(compiler): pick last char when dynamic directive doesn't close e.g.
should compiles to [miss] instead of [mis] --- .../compiler-core/__tests__/__snapshots__/parse.spec.ts.snap | 2 +- packages/compiler-core/src/parse.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap index d14631367cb..d7ac9888a59 100644 --- a/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap @@ -6260,7 +6260,7 @@ Object { Object { "arg": Object { "constType": 0, - "content": "se", + "content": "sef", "isStatic": false, "loc": Object { "end": Object { diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts index 907e54d742e..fd31f17aee7 100644 --- a/packages/compiler-core/src/parse.ts +++ b/packages/compiler-core/src/parse.ts @@ -814,9 +814,10 @@ function parseAttribute( context, ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END ) + content = content.substr(1) + } else { + content = content.substr(1, content.length - 2) } - - content = content.substr(1, content.length - 2) } else if (isSlot) { // #1241 special case for v-slot: vuetify relies extensively on slot // names containing dots. v-slot doesn't have any modifiers and Vue 2.x