remove singular updates

pull/10922/head
Rich Harris 2 years ago
parent 6c85339def
commit 13f5c21678

@ -33,8 +33,6 @@ export interface ComponentClientTransformState extends ClientTransformState {
readonly init: Statement[]; readonly init: Statement[];
/** Stuff that happens inside the render effect */ /** Stuff that happens inside the render effect */
readonly update: { readonly update: {
/** If the update array only contains a single entry, this singular entry will be used, if present */
singular?: Statement;
/** Used if condition for singular prop is false (see comment above) */ /** Used if condition for singular prop is false (see comment above) */
grouped: Statement; grouped: Statement;
}[]; }[];

@ -106,7 +106,7 @@ function serialize_style_directives(style_directives, element_id, context, is_at
if (!is_attributes_reactive && contains_call_expression) { if (!is_attributes_reactive && contains_call_expression) {
state.init.push(singular); state.init.push(singular);
} else if (is_attributes_reactive || directive.metadata.dynamic || contains_call_expression) { } else if (is_attributes_reactive || directive.metadata.dynamic || contains_call_expression) {
state.update.push({ grouped, singular }); state.update.push({ grouped });
} else { } else {
state.init.push(grouped); state.init.push(grouped);
} }
@ -155,7 +155,7 @@ function serialize_class_directives(class_directives, element_id, context, is_at
if (!is_attributes_reactive && contains_call_expression) { if (!is_attributes_reactive && contains_call_expression) {
state.init.push(singular); state.init.push(singular);
} else if (is_attributes_reactive || directive.metadata.dynamic || contains_call_expression) { } else if (is_attributes_reactive || directive.metadata.dynamic || contains_call_expression) {
state.update.push({ grouped, singular }); state.update.push({ grouped });
} else { } else {
state.init.push(grouped); state.init.push(grouped);
} }
@ -334,7 +334,6 @@ function serialize_element_spread_attributes(
} }
} else { } else {
context.state.update.push({ context.state.update.push({
singular: needs_select_handling ? undefined : standalone,
grouped: inside_effect grouped: inside_effect
}); });
} }
@ -414,7 +413,6 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
const id = context.state.scope.generate('spread_attributes'); const id = context.state.scope.generate('spread_attributes');
context.state.init.push(b.let(id)); context.state.init.push(b.let(id));
context.state.update.push({ context.state.update.push({
singular: isolated,
grouped: b.stmt( grouped: b.stmt(
b.assignment( b.assignment(
'=', '=',
@ -566,7 +564,7 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu
if (contains_call_expression && singular) { if (contains_call_expression && singular) {
state.init.push(singular); state.init.push(singular);
} else { } else {
state.update.push({ singular, grouped }); state.update.push({ grouped });
} }
return true; return true;
} else { } else {
@ -710,7 +708,6 @@ function serialize_update_assignment(state, id, init, value, assignment, contain
if (assignment.skip_condition) { if (assignment.skip_condition) {
if (assignment.singular) { if (assignment.singular) {
state.update.push({ state.update.push({
singular: assignment.singular,
grouped: assignment.grouped grouped: assignment.grouped
}); });
} else { } else {
@ -723,7 +720,6 @@ function serialize_update_assignment(state, id, init, value, assignment, contain
if (assignment.singular) { if (assignment.singular) {
state.init.push(b.var(id, init)); state.init.push(b.var(id, init));
state.update.push({ state.update.push({
singular: assignment.singular,
grouped grouped
}); });
} else { } else {
@ -1279,10 +1275,6 @@ function get_template_function(namespace, state) {
* @param {import('../types.js').ComponentClientTransformState} state * @param {import('../types.js').ComponentClientTransformState} state
*/ */
function serialize_render_stmt(state) { function serialize_render_stmt(state) {
if (state.update.length === 1 && state.update[0].singular) {
return state.update[0].singular;
}
return b.stmt(b.call('$.render_effect', b.thunk(b.block(state.update.map((n) => n.grouped))))); return b.stmt(b.call('$.render_effect', b.thunk(b.block(state.update.map((n) => n.grouped)))));
} }

@ -17,7 +17,10 @@ export default function Each_string_template($$anchor, $$props) {
($$anchor, thing, $$index) => { ($$anchor, thing, $$index) => {
var text = $.space_frag($$anchor); var text = $.space_frag($$anchor);
$.text_effect(text, () => `${$.stringify($.unwrap(thing))}, `); $.render_effect(() => {
$.text(text, `${$.stringify($.unwrap(thing))}, `);
});
return $.close($$anchor, text); return $.close($$anchor, text);
}, },
null null

@ -23,7 +23,10 @@ export default function Function_prop_no_getter($$anchor, $$props) {
children: ($$anchor, $$slotProps) => { children: ($$anchor, $$slotProps) => {
var text = $.space_frag($$anchor); var text = $.space_frag($$anchor);
$.text_effect(text, () => `clicks: ${$.stringify($.get(count))}`); $.render_effect(() => {
$.text(text, `clicks: ${$.stringify($.get(count))}`);
});
return $.close($$anchor, text); return $.close($$anchor, text);
} }
}); });

Loading…
Cancel
Save