Skip to content

Commit

Permalink
fix(language-core): ignore unknown attrs error when strictTemplates i…
Browse files Browse the repository at this point in the history
…s not enabled

close #4785
  • Loading branch information
johnsoncodehk committed Sep 4, 2024
1 parent e90ea65 commit f1d453c
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions packages/language-core/lib/codegen/template/elementProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,31 @@ export function* generateElementProps(
if (shouldSpread) {
yield `...{ `;
}
const codeInfo = ctx.codeFeatures.withoutHighlightAndCompletion;
const codeInfo = shouldCamelize
? {
...ctx.codeFeatures.withoutHighlightAndCompletion,
navigation: ctx.codeFeatures.withoutHighlightAndCompletion.navigation
? {
resolveRenameNewName: camelize,
resolveRenameEditText: hyphenateAttr,
}
: false,
}
: {
...ctx.codeFeatures.withoutHighlightAndCompletion,
};
if (!options.vueCompilerOptions.strictTemplates) {
codeInfo.verification = {
shouldReport(_source, code) {
if (String(code) === '2353' || String(code) === '2561') {
return false;
}
return typeof codeInfo.verification === 'object'
? codeInfo.verification.shouldReport?.(_source, code) ?? true
: true;
},
};
}
const codes = conditionWrapWith(
enableCodeFeatures,
prop.loc.start.offset,
Expand All @@ -207,29 +231,7 @@ export function* generateElementProps(
ctx,
prop.name,
prop.loc.start.offset,
shouldCamelize
? {
...codeInfo,
verification: options.vueCompilerOptions.strictTemplates
? codeInfo.verification
: {
shouldReport(_source, code) {
if (String(code) === '2353' || String(code) === '2561') {
return false;
}
return typeof codeInfo.verification === 'object'
? codeInfo.verification.shouldReport?.(_source, code) ?? true
: true;
},
},
navigation: ctx.codeFeatures.withoutHighlightAndCompletion.navigation
? {
resolveRenameNewName: camelize,
resolveRenameEditText: hyphenateAttr,
}
: false,
}
: ctx.codeFeatures.withoutHighlightAndCompletion,
codeInfo,
(prop.loc as any).name_1 ?? ((prop.loc as any).name_1 = {}),
shouldCamelize
),
Expand Down

0 comments on commit f1d453c

Please sign in to comment.