Skip to content

Commit

Permalink
fix(volar/jsx-directive): allow v-slot:default in template tag (#563)
Browse files Browse the repository at this point in the history
* fix(volar/jsx-directive): allow v-slot:default

* chore: add changeset
  • Loading branch information
topsmart20 committed Nov 24, 2023
1 parent ff71e48 commit 900b182
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-cats-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vue-macros/volar': patch
---

allow v-slot:default in template tag
8 changes: 5 additions & 3 deletions packages/volar/src/jsx-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ function transformVSlot({
for (const attr of child.openingElement.attributes.properties) {
if (!ts.isJsxAttribute(attr)) continue
if (isTemplateTag) {
name = ts.isJsxNamespacedName(attr.name)
? attr.name.name
: undefined
name =
ts.isJsxNamespacedName(attr.name) &&
attr.name.name.escapedText !== 'default'
? attr.name.name
: undefined
}

if (
Expand Down
4 changes: 3 additions & 1 deletion playground/vue3/src/examples/jsx-directive/v-slot/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ defineRender(() => (
<fieldset>
<legend>v-slot</legend>
<Comp v-slot={{ foo }}>{''}</Comp>
<Comp>
<template v-slot:default={{ foo }}>{''}</template>
</Comp>
<Child>
<div>default: begin</div>
Expand Down

0 comments on commit 900b182

Please sign in to comment.