@@ -2,6 +2,7 @@ import * as CompilerDOM from '@vue/compiler-dom';
22import { camelize } from '@vue/shared' ;
33import type { Code } from '../../types' ;
44import { hyphenateAttr } from '../../utils/shared' ;
5+ import { codeFeatures } from '../codeFeatures' ;
56import { endOfLine , wrapWith } from '../utils' ;
67import { generateCamelized } from '../utils/camelized' ;
78import { generateStringLiteralKey } from '../utils/stringLiteralKey' ;
@@ -10,6 +11,15 @@ import type { TemplateCodegenOptions } from './index';
1011import { generateInterpolation } from './interpolation' ;
1112import { generateObjectProperty } from './objectProperty' ;
1213
14+ const builtInDirectives = new Set ( [
15+ 'cloak' ,
16+ 'html' ,
17+ 'memo' ,
18+ 'once' ,
19+ 'show' ,
20+ 'text' ,
21+ ] ) ;
22+
1323export function * generateElementDirectives (
1424 options : TemplateCodegenOptions ,
1525 ctx : TemplateCodegenContext ,
@@ -34,7 +44,7 @@ export function* generateElementDirectives(
3444 prop . loc . end . offset ,
3545 ctx . codeFeatures . verification ,
3646 `__VLS_asFunctionalDirective(` ,
37- ...generateIdentifier ( ctx , prop ) ,
47+ ...generateIdentifier ( options , ctx , prop ) ,
3848 `)(null!, { ...__VLS_directiveBindingRestFields, ` ,
3949 ...generateArg ( options , ctx , prop ) ,
4050 ...generateModifiers ( options , ctx , prop ) ,
@@ -46,6 +56,7 @@ export function* generateElementDirectives(
4656}
4757
4858function * generateIdentifier (
59+ options : TemplateCodegenOptions ,
4960 ctx : TemplateCodegenContext ,
5061 prop : CompilerDOM . DirectiveNode
5162) : Generator < Code > {
@@ -58,16 +69,16 @@ function* generateIdentifier(
5869 ...generateCamelized (
5970 rawName ,
6071 prop . loc . start . offset ,
61- {
62- ...ctx . codeFeatures . withoutHighlight ,
72+ ctx . resolveCodeFeatures ( {
73+ ...codeFeatures . withoutHighlight ,
6374 // fix https://github.com/vuejs/language-tools/issues/1905
64- ...ctx . codeFeatures . additionalCompletion ,
65- verification : false ,
75+ ...codeFeatures . additionalCompletion ,
76+ verification : options . vueCompilerOptions . checkUnknownDirectives && ! builtInDirectives . has ( prop . name ) ,
6677 navigation : {
6778 resolveRenameNewName : camelize ,
6879 resolveRenameEditText : getPropRenameApply ( prop . name ) ,
6980 } ,
70- }
81+ } )
7182 )
7283 ) ;
7384}
0 commit comments