Skip to content

Commit

Permalink
fix: don't reassign bound imports on the server
Browse files Browse the repository at this point in the history
fixes #13027
  • Loading branch information
dummdidumm committed Aug 26, 2024
1 parent e366c49 commit e965e57
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-insects-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: don't reassign bound imports on the server
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,28 @@ export function build_inline_component(node, expression, context) {
const value = build_attribute_value(attribute.value, context, false, true);
push_prop(b.prop('init', b.key(attribute.name), value));
} else if (attribute.type === 'BindDirective' && attribute.name !== 'this') {
// TODO this needs to turn the whole thing into a while loop because the binding could be mutated eagerly in the child
push_prop(
b.get(attribute.name, [
b.return(/** @type {Expression} */ (context.visit(attribute.expression)))
])
);
push_prop(
b.set(attribute.name, [
b.stmt(
/** @type {Expression} */ (
context.visit(b.assignment('=', attribute.expression, b.id('$$value')))
)
),
b.stmt(b.assignment('=', b.id('$$settled'), b.false))
])
);
if (
// Don't reassign imports
attribute.expression.type !== 'Identifier' ||
attribute.expression.name !== attribute.name ||
context.state.scope.get(attribute.name)?.declaration_kind !== 'import'
) {
push_prop(
b.set(attribute.name, [
b.stmt(
/** @type {Expression} */ (
context.visit(b.assignment('=', attribute.expression, b.id('$$value')))
)
),
b.stmt(b.assignment('=', b.id('$$settled'), b.false))
])
);
}
}
}

Expand Down

0 comments on commit e965e57

Please sign in to comment.