fix(parser): directive arg should be undefined on shorthands with no arg

This commit is contained in:
Evan You 2023-11-27 18:10:00 +08:00
parent ebaeb2e0aa
commit e49dffc9ec
2 changed files with 12 additions and 0 deletions

View File

@ -1941,6 +1941,17 @@ describe('compiler: parse', () => {
})
})
test('arg should be undefined on shorthand dirs with no arg', () => {
const ast = baseParse(`<template #></template>`)
const el = ast.children[0] as ElementNode
expect(el.props[0]).toMatchObject({
type: NodeTypes.DIRECTIVE,
name: 'slot',
exp: undefined,
arg: undefined
})
})
describe('decodeEntities option', () => {
test('use decode by default', () => {
const ast: any = baseParse('&gt;&lt;&amp;&apos;&quot;&foo;')

View File

@ -238,6 +238,7 @@ const tokenizer = new Tokenizer(stack, {
},
ondirarg(start, end) {
if (start === end) return
const arg = getSlice(start, end)
if (inVPre) {
;(currentProp as AttributeNode).name += arg