Skip to content

Commit f1d453c

Browse files
committed
fix(language-core): ignore unknown attrs error when strictTemplates is not enabled
close #4785
1 parent e90ea65 commit f1d453c

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

packages/language-core/lib/codegen/template/elementProps.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,31 @@ export function* generateElementProps(
196196
if (shouldSpread) {
197197
yield `...{ `;
198198
}
199-
const codeInfo = ctx.codeFeatures.withoutHighlightAndCompletion;
199+
const codeInfo = shouldCamelize
200+
? {
201+
...ctx.codeFeatures.withoutHighlightAndCompletion,
202+
navigation: ctx.codeFeatures.withoutHighlightAndCompletion.navigation
203+
? {
204+
resolveRenameNewName: camelize,
205+
resolveRenameEditText: hyphenateAttr,
206+
}
207+
: false,
208+
}
209+
: {
210+
...ctx.codeFeatures.withoutHighlightAndCompletion,
211+
};
212+
if (!options.vueCompilerOptions.strictTemplates) {
213+
codeInfo.verification = {
214+
shouldReport(_source, code) {
215+
if (String(code) === '2353' || String(code) === '2561') {
216+
return false;
217+
}
218+
return typeof codeInfo.verification === 'object'
219+
? codeInfo.verification.shouldReport?.(_source, code) ?? true
220+
: true;
221+
},
222+
};
223+
}
200224
const codes = conditionWrapWith(
201225
enableCodeFeatures,
202226
prop.loc.start.offset,
@@ -207,29 +231,7 @@ export function* generateElementProps(
207231
ctx,
208232
prop.name,
209233
prop.loc.start.offset,
210-
shouldCamelize
211-
? {
212-
...codeInfo,
213-
verification: options.vueCompilerOptions.strictTemplates
214-
? codeInfo.verification
215-
: {
216-
shouldReport(_source, code) {
217-
if (String(code) === '2353' || String(code) === '2561') {
218-
return false;
219-
}
220-
return typeof codeInfo.verification === 'object'
221-
? codeInfo.verification.shouldReport?.(_source, code) ?? true
222-
: true;
223-
},
224-
},
225-
navigation: ctx.codeFeatures.withoutHighlightAndCompletion.navigation
226-
? {
227-
resolveRenameNewName: camelize,
228-
resolveRenameEditText: hyphenateAttr,
229-
}
230-
: false,
231-
}
232-
: ctx.codeFeatures.withoutHighlightAndCompletion,
234+
codeInfo,
233235
(prop.loc as any).name_1 ?? ((prop.loc as any).name_1 = {}),
234236
shouldCamelize
235237
),

0 commit comments

Comments
 (0)