remove spread_attributes_effect

pull/10922/head
Rich Harris 2 years ago
parent 630e571112
commit 8c11e70794

@ -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) {

@ -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<string, unknown>[]} attrs
* @param {boolean} lowercase_attributes
* @param {string} css_hash
*/
export function spread_attributes_effect(dom, attrs, lowercase_attributes, css_hash) {
/** @type {Record<string, any> | 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

Loading…
Cancel
Save