mirror of https://github.com/vuejs/core.git
fix(compiler-core): avoid self updates of `v-pre` (#12556)
This commit is contained in:
parent
ce933390ad
commit
21b685ad9d
|
@ -43,6 +43,7 @@ import {
|
||||||
isCoreComponent,
|
isCoreComponent,
|
||||||
isSimpleIdentifier,
|
isSimpleIdentifier,
|
||||||
isStaticArgOf,
|
isStaticArgOf,
|
||||||
|
isVPre,
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import { decodeHTML } from 'entities/lib/decode.js'
|
import { decodeHTML } from 'entities/lib/decode.js'
|
||||||
import {
|
import {
|
||||||
|
@ -246,7 +247,7 @@ const tokenizer = new Tokenizer(stack, {
|
||||||
ondirarg(start, end) {
|
ondirarg(start, end) {
|
||||||
if (start === end) return
|
if (start === end) return
|
||||||
const arg = getSlice(start, end)
|
const arg = getSlice(start, end)
|
||||||
if (inVPre) {
|
if (inVPre && !isVPre(currentProp!)) {
|
||||||
;(currentProp as AttributeNode).name += arg
|
;(currentProp as AttributeNode).name += arg
|
||||||
setLocEnd((currentProp as AttributeNode).nameLoc, end)
|
setLocEnd((currentProp as AttributeNode).nameLoc, end)
|
||||||
} else {
|
} else {
|
||||||
|
@ -262,7 +263,7 @@ const tokenizer = new Tokenizer(stack, {
|
||||||
|
|
||||||
ondirmodifier(start, end) {
|
ondirmodifier(start, end) {
|
||||||
const mod = getSlice(start, end)
|
const mod = getSlice(start, end)
|
||||||
if (inVPre) {
|
if (inVPre && !isVPre(currentProp!)) {
|
||||||
;(currentProp as AttributeNode).name += '.' + mod
|
;(currentProp as AttributeNode).name += '.' + mod
|
||||||
setLocEnd((currentProp as AttributeNode).nameLoc, end)
|
setLocEnd((currentProp as AttributeNode).nameLoc, end)
|
||||||
} else if ((currentProp as DirectiveNode).name === 'slot') {
|
} else if ((currentProp as DirectiveNode).name === 'slot') {
|
||||||
|
|
|
@ -343,6 +343,10 @@ export function isText(
|
||||||
return node.type === NodeTypes.INTERPOLATION || node.type === NodeTypes.TEXT
|
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 {
|
export function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode {
|
||||||
return p.type === NodeTypes.DIRECTIVE && p.name === 'slot'
|
return p.type === NodeTypes.DIRECTIVE && p.name === 'slot'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue