10000 fix(volar/jsx-directive): allow dynamic v-slot without expression (#953) · vue-macros/vue-macros@33b4183 · GitHub
[go: up one dir, main page]

Skip to content

Commit 33b4183

Browse files
authored
fix(volar/jsx-directive): allow dynamic v-slot without expression (#953)
1 parent 177fa15 commit 33b4183

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

packages/jsx-directive/tests/__snapshots__/v-slot.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defineRender(() => (
2929
<div>
3030
<Child v-slots={{'bottom': ({ foo }) => <>
3131
{foo}
32-
<Child v-slots={{'default': () => <>default</>,$stable: true,}}></Child>
32+
<Child v-slots={{[baz]: () => <>default</>,}}></Child>
3333
</>,$stable: true,}}></Child>
3434
3535
<Comp v-slots={{'default': () => <>default</>,$stable: true,}}></Comp>

packages/jsx-directive/tests/fixtures/v-slot/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defineRender(() => (
2525
<div>
2626
<Child v-slot:bottom={{ foo }}>
2727
{foo}
28-
<Child v-slot>default</Child>
28+
<Child v-slot:$baz$>default</Child>
2929
</Child>
3030
3131
<Comp v-slot>default</Comp>

packages/volar/src/jsx-directive/v-slot.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,19 @@ export function transformVSlot(
9191
]
9292
: 'default',
9393
`: (`,
94-
(!isNamespace || attributeName) &&
95-
isJsxExpression(attribute.initializer) &&
96-
attribute.initializer.expression
97-
? ([
98-
getText(attribute.initializer.expression, options),
99-
source,
100-
getStart(attribute.initializer.expression, options),
101-
allCodeFeatures,
102-
] as Code)
103-
: '',
104-
isDynamic ? ': any' : '',
94+
...((!isNamespace || attributeName) &&
95+
isJsxExpression(attribute.initializer) &&
96+
attribute.initializer.expression
97+
? [
98+
[
99+
getText(attribute.initializer.expression, options),
100+
source,
101+
getStart(attribute.initializer.expression, options),
102+
allCodeFeatures,
103+
] as Code,
104+
isDynamic ? ': any' : '',
105+
]
106+
: []),
105107
') => <>',
106108
...children.map((child) => {
107109
replaceSourceRange(codes, source, child.pos, child.end)

0 commit comments

Comments
 (0)
0