Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/language-server/tests/completions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,31 @@ test('Auto import', async () => {
`);
});

test('Boolean props', async () => {
await requestCompletionItemToVueServer(
'fixture.vue',
'vue',
`
<template>
<Comp :f| />
</template>

<script setup lang="ts">
declare function Comp(props: { foo: boolean }): void;
</script>
`,
':foo',
);
});

test('Directives', async () => {
await requestCompletionItemToVueServer('fixture.vue', 'vue', `<template><div v-ht|></div></template>`, 'v-html');
await requestCompletionItemToVueServer('fixture.vue', 'vue', `<template><div v-cl|></div></template>`, 'v-cloak');
await requestCompletionItemToVueServer('fixture.vue', 'vue', `<template><div v-el|></div></template>`, 'v-else');
await requestCompletionItemToVueServer('fixture.vue', 'vue', `<template><div v-p|></div></template>`, 'v-pre');
});

test('Directive Modifiers', async () => {
test('Directive modifiers', async () => {
expect(
(await requestCompletionListToVueServer(
'fixture.vue',
Expand Down
4 changes: 4 additions & 0 deletions packages/language-service/lib/plugins/vue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ export function create(
const name = attrNameCasing === AttrNameCasing.Camel ? prop.name : hyphenateAttr(prop.name);
return name === labelName;
});
const isBoolean = propMeta2?.type === 'boolean' || propMeta2?.type.startsWith('boolean ');

if (addPlainAttrs) {
attributes.push({
name: labelName,
Expand All @@ -775,12 +777,14 @@ export function create(
attributes.push({
name: V_BIND_SHORTHAND + labelName,
description: propMeta2 && createDescription(propMeta2),
valueSet: isBoolean ? 'v' : undefined,
});
}
if (addVBinds) {
attributes.push({
name: DIRECTIVE_V_BIND + labelName,
description: propMeta2 && createDescription(propMeta2),
valueSet: isBoolean ? 'v' : undefined,
});
}
}
Expand Down