Skip to content

Commit

Permalink
fix(parser): directive arg should be undefined on shorthands with no arg
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 27, 2023
1 parent ebaeb2e commit e49dffc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/compiler-core/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;')
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e49dffc

Please sign in to comment.