Skip to content

Commit 13f5c21

Browse files
committed
remove singular updates
1 parent 6c85339 commit 13f5c21

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

packages/svelte/src/compiler/phases/3-transform/client/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export interface ComponentClientTransformState extends ClientTransformState {
3333
readonly init: Statement[];
3434
/** Stuff that happens inside the render effect */
3535
readonly update: {
36-
/** If the update array only contains a single entry, this singular entry will be used, if present */
37-
singular?: Statement;
3836
/** Used if condition for singular prop is false (see comment above) */
3937
grouped: Statement;
4038
}[];

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function serialize_style_directives(style_directives, element_id, context, is_at
106106
if (!is_attributes_reactive && contains_call_expression) {
107107
state.init.push(singular);
108108
} else if (is_attributes_reactive || directive.metadata.dynamic || contains_call_expression) {
109-
state.update.push({ grouped, singular });
109+
state.update.push({ grouped });
110110
} else {
111111
state.init.push(grouped);
112112
}
@@ -155,7 +155,7 @@ function serialize_class_directives(class_directives, element_id, context, is_at
155155
if (!is_attributes_reactive && contains_call_expression) {
156156
state.init.push(singular);
157157
} else if (is_attributes_reactive || directive.metadata.dynamic || contains_call_expression) {
158-
state.update.push({ grouped, singular });
158+
state.update.push({ grouped });
159159
} else {
160160
state.init.push(grouped);
161161
}
@@ -334,7 +334,6 @@ function serialize_element_spread_attributes(
334334
}
335335
} else {
336336
context.state.update.push({
337-
singular: needs_select_handling ? undefined : standalone,
338337
grouped: inside_effect
339338
});
340339
}
@@ -414,7 +413,6 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
414413
const id = context.state.scope.generate('spread_attributes');
415414
context.state.init.push(b.let(id));
416415
context.state.update.push({
417-
singular: isolated,
418416
grouped: b.stmt(
419417
b.assignment(
420418
'=',
@@ -566,7 +564,7 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu
566564
if (contains_call_expression && singular) {
567565
state.init.push(singular);
568566
} else {
569-
state.update.push({ singular, grouped });
567+
state.update.push({ grouped });
570568
}
571569
return true;
572570
} else {
@@ -710,7 +708,6 @@ function serialize_update_assignment(state, id, init, value, assignment, contain
710708
if (assignment.skip_condition) {
711709
if (assignment.singular) {
712710
state.update.push({
713-
singular: assignment.singular,
714711
grouped: assignment.grouped
715712
});
716713
} else {
@@ -723,7 +720,6 @@ function serialize_update_assignment(state, id, init, value, assignment, contain
723720
if (assignment.singular) {
724721
state.init.push(b.var(id, init));
725722
state.update.push({
726-
singular: assignment.singular,
727723
grouped
728724
});
729725
} else {
@@ -1279,10 +1275,6 @@ function get_template_function(namespace, state) {
12791275
* @param {import('../types.js').ComponentClientTransformState} state
12801276
*/
12811277
function serialize_render_stmt(state) {
1282-
if (state.update.length === 1 && state.update[0].singular) {
1283-
return state.update[0].singular;
1284-
}
1285-
12861278
return b.stmt(b.call('$.render_effect', b.thunk(b.block(state.update.map((n) => n.grouped)))));
12871279
}
12881280

packages/svelte/tests/snapshot/samples/each-string-template/_expected/client/index.svelte.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export default function Each_string_template($$anchor, $$props) {
1717
($$anchor, thing, $$index) => {
1818
var text = $.space_frag($$anchor);
1919

20-
$.text_effect(text, () => `${$.stringify($.unwrap(thing))}, `);
20+
$.render_effect(() => {
21+
$.text(text, `${$.stringify($.unwrap(thing))}, `);
22+
});
23+
2124
return $.close($$anchor, text);
2225
},
2326
null

packages/svelte/tests/snapshot/samples/function-prop-no-getter/_expected/client/index.svelte.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export default function Function_prop_no_getter($$anchor, $$props) {
2323
children: ($$anchor, $$slotProps) => {
2424
var text = $.space_frag($$anchor);
2525

26-
$.text_effect(text, () => `clicks: ${$.stringify($.get(count))}`);
26+
$.render_effect(() => {
27+
$.text(text, `clicks: ${$.stringify($.get(count))}`);
28+
});
29+
2730
return $.close($$anchor, text);
2831
}
2932
});

0 commit comments

Comments
 (0)