From: 山吹色御守 <85992002+KazariEX@users.noreply.github.com> Date: Fri, 18 Jul 2025 08:22:56 +0000 (-0700) Subject: fix(compiler-core): avoid self updates of `v-pre` (#12556) X-Git-Tag: v3.5.18~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=21b685ad9d9d0e6060fc7d07b719bf35f2d9ae1f;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-core): avoid self updates of `v-pre` (#12556) --- diff --git a/packages/compiler-core/src/parser.ts b/packages/compiler-core/src/parser.ts index 3eb3a976f4..a6e25681d7 100644 --- a/packages/compiler-core/src/parser.ts +++ b/packages/compiler-core/src/parser.ts @@ -43,6 +43,7 @@ import { isCoreComponent, isSimpleIdentifier, isStaticArgOf, + isVPre, } from './utils' import { decodeHTML } from 'entities/lib/decode.js' import { @@ -246,7 +247,7 @@ const tokenizer = new Tokenizer(stack, { ondirarg(start, end) { if (start === end) return const arg = getSlice(start, end) - if (inVPre) { + if (inVPre && !isVPre(currentProp!)) { ;(currentProp as AttributeNode).name += arg setLocEnd((currentProp as AttributeNode).nameLoc, end) } else { @@ -262,7 +263,7 @@ const tokenizer = new Tokenizer(stack, { ondirmodifier(start, end) { const mod = getSlice(start, end) - if (inVPre) { + if (inVPre && !isVPre(currentProp!)) { ;(currentProp as AttributeNode).name += '.' + mod setLocEnd((currentProp as AttributeNode).nameLoc, end) } else if ((currentProp as DirectiveNode).name === 'slot') { diff --git a/packages/compiler-core/src/utils.ts b/packages/compiler-core/src/utils.ts index 113096cef2..ab851ed6f6 100644 --- a/packages/compiler-core/src/utils.ts +++ b/packages/compiler-core/src/utils.ts @@ -343,6 +343,10 @@ export function isText( return node.type === NodeTypes.INTERPOLATION || node.type === NodeTypes.TEXT } +export function isVPre(p: ElementNode['props'][0]): p is DirectiveNode { + return p.type === NodeTypes.DIRECTIVE && p.name === 'pre' +} + export function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode { return p.type === NodeTypes.DIRECTIVE && p.name === 'slot' }