Skip to content

Commit 21b685a

Browse files
authored
fix(compiler-core): avoid self updates of v-pre (#12556)
1 parent ce93339 commit 21b685a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/compiler-core/src/parser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
isCoreComponent,
4444
isSimpleIdentifier,
4545
isStaticArgOf,
46+
isVPre,
4647
} from './utils'
4748
import { decodeHTML } from 'entities/lib/decode.js'
4849
import {
@@ -246,7 +247,7 @@ const tokenizer = new Tokenizer(stack, {
246247
ondirarg(start, end) {
247248
if (start === end) return
248249
const arg = getSlice(start, end)
249-
if (inVPre) {
250+
if (inVPre && !isVPre(currentProp!)) {
250251
;(currentProp as AttributeNode).name += arg
251252
setLocEnd((currentProp as AttributeNode).nameLoc, end)
252253
} else {
@@ -262,7 +263,7 @@ const tokenizer = new Tokenizer(stack, {
262263

263264
ondirmodifier(start, end) {
264265
const mod = getSlice(start, end)
265-
if (inVPre) {
266+
if (inVPre && !isVPre(currentProp!)) {
266267
;(currentProp as AttributeNode).name += '.' + mod
267268
setLocEnd((currentProp as AttributeNode).nameLoc, end)
268269
} else if ((currentProp as DirectiveNode).name === 'slot') {

packages/compiler-core/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ export function isText(
343343
return node.type === NodeTypes.INTERPOLATION || node.type === NodeTypes.TEXT
344344
}
345345

346+
export function isVPre(p: ElementNode['props'][0]): p is DirectiveNode {
347+
return p.type === NodeTypes.DIRECTIVE && p.name === 'pre'
348+
}
349+
346350
export function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode {
347351
return p.type === NodeTypes.DIRECTIVE && p.name === 'slot'
348352
}

0 commit comments

Comments
 (0)