Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(language-core): inlay hints for <component :is> and <slot :name> #4661

Merged
merged 12 commits into from
Oct 23, 2024
Prev Previous commit
Update element.ts
  • Loading branch information
johnsoncodehk committed Oct 23, 2024
commit 4c7c7c829af329eb6b5c21f2b6a79f266666c783
10 changes: 5 additions & 5 deletions packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export function* generateComponent(

let props = node.props;
let dynamicTagInfo: {
exp: CompilerDOM.ElementNode | CompilerDOM.ExpressionNode;
tag: string;
offsets: [number, number | undefined];
astHolder: CompilerDOM.SourceLocation;
} | undefined;

if (isComponentTag) {
Expand All @@ -66,9 +66,9 @@ export function* generateComponent(
ctx.inlayHints.push(createVBindShorthandInlayHintInfo(prop.exp.loc, 'is'));
}
dynamicTagInfo = {
exp: prop.exp,
tag: prop.exp.content,
offsets: [prop.exp.loc.start.offset, undefined],
astHolder: prop.exp.loc,
};
props = props.filter(p => p !== prop);
break;
Expand All @@ -78,9 +78,9 @@ export function* generateComponent(
else if (node.tag.includes('.')) {
// namespace tag
dynamicTagInfo = {
exp: node,
tag: node.tag,
offsets: [startTagOffset, endTagOffset],
astHolder: node.loc,
};
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export function* generateComponent(
options,
ctx,
dynamicTagInfo.tag,
dynamicTagInfo.exp,
dynamicTagInfo.astHolder,
dynamicTagInfo.offsets[0],
ctx.codeFeatures.all,
'(',
Expand All @@ -132,7 +132,7 @@ export function* generateComponent(
options,
ctx,
dynamicTagInfo.tag,
dynamicTagInfo.exp,
dynamicTagInfo.astHolder,
dynamicTagInfo.offsets[1],
{
...ctx.codeFeatures.all,
Expand Down