diff --git a/src/compiler/compile/render_ssr/handlers/shared/get_attribute_value.ts b/src/compiler/compile/render_ssr/handlers/shared/get_attribute_value.ts index 6c3aad7456..c6a1b7087a 100644 --- a/src/compiler/compile/render_ssr/handlers/shared/get_attribute_value.ts +++ b/src/compiler/compile/render_ssr/handlers/shared/get_attribute_value.ts @@ -1,43 +1,52 @@ -import Attribute from '../../../nodes/Attribute'; -import { string_literal } from '../../../utils/stringify'; -import Text from '../../../nodes/Text'; +import { string_literal } from '../../../utils/stringify.js'; import { x } from 'code-red'; -import Expression from '../../../nodes/shared/Expression'; -import { Expression as ESTreeExpression } from 'estree'; -import { regex_double_quotes } from '../../../../utils/patterns'; +import { regex_double_quotes } from '../../../../utils/patterns.js'; -export function get_class_attribute_value(attribute: Attribute): ESTreeExpression { - // handle special case — `class={possiblyUndefined}` with scoped CSS - if (attribute.chunks.length === 2 && (attribute.chunks[1] as Text).synthetic) { - const value = (attribute.chunks[0] as Expression).node; - return x`@escape(@null_to_empty(${value}), true) + "${(attribute.chunks[1] as Text).data}"`; - } +/** + * @param {import('../../../nodes/Attribute.js').default} attribute + * @returns {import("C:/repos/svelte/svelte/node_modules/.pnpm/@types+estree@1.0.0/node_modules/@types/estree/index").Expression} + */ +export function get_class_attribute_value(attribute) { + // handle special case — `class={possiblyUndefined}` with scoped CSS + if (attribute.chunks.length === 2 && ( /** @type {import('../../../nodes/Text.js').default} */(attribute.chunks[1])).synthetic) { + const value = ( /** @type {import('../../../nodes/shared/Expression.js').default} */(attribute.chunks[0])).node; + return x `@escape(@null_to_empty(${value}), true) + "${( /** @type {import('../../../nodes/Text.js').default} */(attribute.chunks[1])).data}"`; + } + return get_attribute_value(attribute); +} - return get_attribute_value(attribute); +/** + * @param {import('../../../nodes/Attribute.js').default} attribute + * @returns {import("C:/repos/svelte/svelte/node_modules/.pnpm/@types+estree@1.0.0/node_modules/@types/estree/index").Expression} + */ +export function get_attribute_value(attribute) { + if (attribute.chunks.length === 0) + return x `""`; + /** + * For value attribute of textarea, it will render as child node of `