From 2ace748ff5da6230b420dff57ed8c16a1bba3496 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 14 Nov 2024 14:26:21 -0800 Subject: [PATCH] fix(ssr): fix rendering of `spellcheck` attribute --- .../ssr-compiler/src/__tests__/utils/expected-failures.ts | 1 - .../src/compile-template/transformers/component.ts | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts index 35abd4f960..b559ecd35f 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts @@ -32,7 +32,6 @@ export const expectedFailures = new Set([ 'dynamic-components/index.js', 'dynamic-slots/index.js', 'empty-text-with-comments-non-static-optimized/index.js', - 'global-html-attributes/index.js', 'if-conditional-slot-content/index.js', 'rehydration/index.js', 'render-dynamic-value/index.js', diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/component.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/component.ts index 03e79bcf31..d61dc1d96c 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/component.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/component.ts @@ -101,7 +101,7 @@ function getChildAttrsOrProps( .map(({ name, value, type }) => { const key = isValidIdentifier(name) ? b.identifier(name) : b.literal(name); if (value.type === 'Literal' && typeof value.value === 'string') { - let literalValue = value.value; + let literalValue: string | boolean = value.value; if (name === 'style') { literalValue = normalizeStyleAttributeValue(literalValue); } else if (name === 'class') { @@ -109,6 +109,10 @@ function getChildAttrsOrProps( if (literalValue === '') { return; // do not render empty `class=""` } + } else if (name === 'spellcheck') { + // `spellcheck` string values are specially handled to massage them into booleans: + // https://github.com/salesforce/lwc/blob/574ffbd/packages/%40lwc/template-compiler/src/codegen/index.ts#L445-L448 + literalValue = literalValue.toLowerCase() !== 'false'; } return b.property('init', key, b.literal(literalValue)); } else if (value.type === 'Literal' && typeof value.value === 'boolean') {