From f6777926660fa78048a1b99846ce0d90a192e22d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 21 May 2025 17:23:03 -0400 Subject: [PATCH] fix --- .../client/transform-template/to-functions.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 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 48853a5c44..6fbe17ecae 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 @@ -22,25 +22,30 @@ function build(item) { case 'element': { const element = b.object([b.prop('init', b.id('e'), b.literal(item.name))]); - const entries = Object.entries(item.attributes); - if (entries.length > 0) { - element.properties.push( + if (item.attributes.is) { + element.properties.push(b.prop('init', b.id('is'), b.literal(item.attributes.is))); + } + + const attributes = b.prop('init', b.id('p'), b.object([])); + + for (const key in item.attributes) { + if (key === 'is') continue; + + const value = item.attributes[key]; + + attributes.value.properties.push( b.prop( 'init', - b.id('p'), - b.object( - entries.map(([key, value]) => { - return b.prop( - 'init', - b.key(fix_attribute_casing(key)), - value === undefined ? b.void0 : b.literal(value) - ); - }) - ) + b.key(fix_attribute_casing(key)), + value === undefined ? b.void0 : b.literal(value) ) ); } + if (attributes.value.properties.length > 0) { + element.properties.push(attributes); + } + if (item.children.length > 0) { const children = item.children.map(build); element.properties.push(b.prop('init', b.id('c'), b.array(children)));