From 1e6d85b58e627e013c544245c8a4acc70e9b7af5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 21 May 2025 17:17:45 -0400 Subject: [PATCH] fixes --- .../client/transform-template/to-functions.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-functions.js b/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-functions.js index 6bf86290e6..48853a5c44 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-functions.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/transform-template/to-functions.js @@ -8,6 +8,11 @@ import fix_attribute_casing from './fix-attribute-casing.js'; * @param {Node[]} items */ export function template_to_functions(items) { + // if the first item is a comment we need to add another comment for effect.start + if (items[0].type === 'anchor') { + items.unshift({ type: 'anchor', data: undefined }); + } + return b.array(items.map(build)); } @@ -25,7 +30,11 @@ function build(item) { b.id('p'), b.object( entries.map(([key, value]) => { - return b.prop('init', b.key(key), value === undefined ? b.void0 : b.literal(value)); + return b.prop( + 'init', + b.key(fix_attribute_casing(key)), + value === undefined ? b.void0 : b.literal(value) + ); }) ) ) @@ -33,7 +42,19 @@ function build(item) { } if (item.children.length > 0) { - element.properties.push(b.prop('init', b.id('c'), b.array(item.children.map(build)))); + const children = item.children.map(build); + element.properties.push(b.prop('init', b.id('c'), b.array(children))); + + // special case — strip leading newline from `
` and `