From 8c11e70794f4b3622e28bf2e71ad33e27d6d3552 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 25 Mar 2024 14:04:56 -0400 Subject: [PATCH] remove spread_attributes_effect --- .../3-transform/client/visitors/template.js | 25 +++---------------- .../client/dom/elements/attributes.js | 16 ------------ 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js index 07334845f9..7fe770d706 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js @@ -282,16 +282,7 @@ function serialize_element_spread_attributes( element.metadata.svg || is_custom_element_node(element) ? b.false : b.true; const id = context.state.scope.generate('spread_attributes'); - const standalone = b.stmt( - b.call( - '$.spread_attributes_effect', - element_id, - b.thunk(b.array(values)), - lowercase_attributes, - b.literal(context.state.analysis.css.hash) - ) - ); - const inside_effect = b.stmt( + const update = b.stmt( b.assignment( '=', b.id(id), @@ -306,21 +297,13 @@ function serialize_element_spread_attributes( ) ); - if (!needs_isolation || needs_select_handling) { - context.state.init.push(b.let(id)); - } + context.state.init.push(b.let(id)); // objects could contain reactive getters -> play it safe and always assume spread attributes are reactive if (needs_isolation) { - if (needs_select_handling) { - context.state.init.push( - b.stmt(b.call('$.render_effect', b.arrow([], b.block([inside_effect])))) - ); - } else { - context.state.init.push(standalone); - } + context.state.init.push(serialize_update(update)); } else { - context.state.update.push(inside_effect); + context.state.update.push(update); } if (needs_select_handling) { diff --git a/packages/svelte/src/internal/client/dom/elements/attributes.js b/packages/svelte/src/internal/client/dom/elements/attributes.js index 50b18bdd2e..afcc2b8d1c 100644 --- a/packages/svelte/src/internal/client/dom/elements/attributes.js +++ b/packages/svelte/src/internal/client/dom/elements/attributes.js @@ -108,22 +108,6 @@ export function set_custom_element_data(node, prop, value) { } } -/** - * Like `spread_attributes` but self-contained - * @param {Element & ElementCSSInlineStyle} dom - * @param {() => Record[]} attrs - * @param {boolean} lowercase_attributes - * @param {string} css_hash - */ -export function spread_attributes_effect(dom, attrs, lowercase_attributes, css_hash) { - /** @type {Record | undefined} */ - var current; - - render_effect(() => { - current = spread_attributes(dom, current, attrs(), lowercase_attributes, css_hash); - }); -} - /** * Spreads attributes onto a DOM element, taking into account the currently set attributes * @param {Element & ElementCSSInlineStyle} element