Skip to content

Commit f81b19d

Browse files
authored
Apply suggestions from code review
1 parent bdcbe2f commit f81b19d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
535535

536536
if (name === 'class') {
537537
if (attribute.metadata.expression.has_state && has_call) {
538+
// ensure we're not creating a separate template effect for this so that
539+
// potential class directives are added to the same effect and therefore always apply
538540
const id = b.id(state.scope.generate('class_derived'));
539541
state.init.push(b.const(id, create_derived(state, b.thunk(value))));
540542
value = b.call('$.get', id);
@@ -555,6 +557,8 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
555557
update = b.stmt(b.assignment('=', b.member(node_id, name), value));
556558
} else {
557559
if (name === 'style' && attribute.metadata.expression.has_state && has_call) {
560+
// ensure we're not creating a separate template effect for this so that
561+
// potential style directives are added to the same effect and therefore always apply
558562
const id = b.id(state.scope.generate('style_derived'));
559563
state.init.push(b.const(id, create_derived(state, b.thunk(value))));
560564
value = b.call('$.get', id);

0 commit comments

Comments
 (0)