]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(parser): directive arg should be undefined on shorthands with no arg
authorEvan You <yyx990803@gmail.com>
Mon, 27 Nov 2023 10:10:00 +0000 (18:10 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 27 Nov 2023 10:10:00 +0000 (18:10 +0800)
packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/src/parser.ts

index 7eb5a000e5e441c06e3162126f78d3d02fbb2b12..a116d22c148c9c5123c2f4120ffb94ea149f7178 100644 (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;')
index 9effa0250e31012e0f787104d7cdef3924bdb5c3..4e3c21480a26c63c85a75ff550c2923e468c40ff 100644 (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