get rid of spread_dynamic_element_attributes_effect

pull/10922/head
Rich Harris 2 years ago
parent 0f56430711
commit bfd95701cd

@ -343,6 +343,8 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
return false;
}
// TODO why are we always treating this as a spread? needs docs, if that's not an error
let needs_isolation = false;
let is_reactive = false;
@ -365,23 +367,11 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
attribute.type === 'SpreadAttribute' && attribute.metadata.contains_call_expression;
}
const isolated = b.stmt(
b.call(
'$.spread_dynamic_element_attributes_effect',
element_id,
b.thunk(b.array(values)),
b.literal(context.state.analysis.css.hash)
)
);
if (needs_isolation) {
context.state.init.push(isolated);
return false;
} else if (is_reactive) {
if (needs_isolation || is_reactive) {
const id = context.state.scope.generate('spread_attributes');
context.state.init.push(b.let(id));
context.state.update.push(
b.stmt(
const update = b.stmt(
b.assignment(
'=',
b.id(id),
@ -393,10 +383,17 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
b.literal(context.state.analysis.css.hash)
)
)
)
);
if (needs_isolation) {
context.state.init.push(serialize_update(update));
return false;
}
context.state.update.push(update);
return true;
} else {
}
context.state.init.push(
b.stmt(
b.call(
@ -410,7 +407,6 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
);
return false;
}
}
/**
* Serializes an assignment to an element property by adding relevant statements to either only

@ -184,20 +184,6 @@ export function spread_attributes(element, prev, attrs, lowercase_attributes, cs
return next;
}
/**
* @param {Element} node
* @param {() => Record<string, unknown>[]} attrs
* @param {string} css_hash
*/
export function spread_dynamic_element_attributes_effect(node, attrs, css_hash) {
/** @type {Record<string, any> | undefined} */
var current;
render_effect(() => {
current = spread_dynamic_element_attributes(node, current, attrs(), css_hash);
});
}
/**
* @param {Element} node
* @param {Record<string, unknown> | undefined} prev

Loading…
Cancel
Save