Skip to content

Commit 6eb70f8

Browse files
authored
fix: remove bind_prop in runes mode (#11321)
1 parent 476f217 commit 6eb70f8

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

.changeset/lucky-geckos-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: remove `bind_prop` in runes mode

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,6 @@ export function client_component(source, analysis, options) {
232232
group_binding_declarations.push(b.const(group.name, b.array([])));
233233
}
234234

235-
// Bind static exports to props so that people can access them with bind:x
236-
const static_bindings = analysis.exports.map(({ name, alias }) => {
237-
return b.stmt(
238-
b.call(
239-
'$.bind_prop',
240-
b.id('$$props'),
241-
b.literal(alias ?? name),
242-
serialize_get_binding(b.id(name), instance_state)
243-
)
244-
);
245-
});
246-
247235
const component_returned_object = analysis.exports.map(({ name, alias }) => {
248236
const expression = serialize_get_binding(b.id(name), instance_state);
249237

@@ -369,10 +357,25 @@ export function client_component(source, analysis, options) {
369357
...group_binding_declarations,
370358
.../** @type {import('estree').Statement[]} */ (instance.body),
371359
analysis.runes ? b.empty : b.stmt(b.call('$.init')),
372-
.../** @type {import('estree').Statement[]} */ (template.body),
373-
...static_bindings
360+
.../** @type {import('estree').Statement[]} */ (template.body)
374361
]);
375362

363+
if (!analysis.runes) {
364+
// Bind static exports to props so that people can access them with bind:x
365+
for (const { name, alias } of analysis.exports) {
366+
component_block.body.push(
367+
b.stmt(
368+
b.call(
369+
'$.bind_prop',
370+
b.id('$$props'),
371+
b.literal(alias ?? name),
372+
serialize_get_binding(b.id(name), instance_state)
373+
)
374+
)
375+
);
376+
}
377+
}
378+
376379
const append_styles =
377380
analysis.inject_styles && analysis.css.ast
378381
? () =>

0 commit comments

Comments
 (0)