Skip to content

Commit

Permalink
fix: #932 fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Jan 21, 2025
1 parent 97ad9d8 commit 6e97d23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
22 changes: 1 addition & 21 deletions packages/language-core/lib/codegen/template/elementChildren.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as CompilerDOM from '@vue/compiler-dom';
import type { Code } from '../../types';
import { endOfLine, wrapWith } from '../utils';
import type { TemplateCodegenContext } from './context';
import type { TemplateCodegenOptions } from './index';
import { generateTemplateChild } from './templateChild';

export function* generateElementChildren(
options: TemplateCodegenOptions,
ctx: TemplateCodegenContext,
node: CompilerDOM.ElementNode,
isDefaultSlot: boolean = false
node: CompilerDOM.ElementNode
): Generator<Code> {
yield* ctx.resetDirectiveComments('end of element children start');
let prev: CompilerDOM.TemplateChildNode | undefined;
Expand All @@ -18,22 +16,4 @@ export function* generateElementChildren(
prev = childNode;
}
yield* ctx.generateAutoImportCompletion();

// fix https://github.com/vuejs/language-tools/issues/932
if (
ctx.currentComponent
&& isDefaultSlot
&& node.children.length
&& node.tagType === CompilerDOM.ElementTypes.COMPONENT
) {
ctx.currentComponent.used = true;
yield `${ctx.currentComponent.ctxVar}.slots!.`;
yield* wrapWith(
node.children[0].loc.start.offset,
node.children[node.children.length - 1].loc.end.offset,
ctx.codeFeatures.navigation,
`default`
);
yield endOfLine;
}
}
7 changes: 6 additions & 1 deletion packages/language-core/lib/codegen/template/vSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export function* generateVSlot(
}
}
else {
yield `default`;
yield* wrapWith(
node.children[0].loc.start.offset,
node.children.at(-1)!.loc.end.offset,
ctx.codeFeatures.navigation,
`default`
);
}
yield `: ${var_slot} } = ${ctx.currentComponent.ctxVar}.slots!${endOfLine}`;
}
Expand Down

0 comments on commit 6e97d23

Please sign in to comment.