fix: remove `bind_prop` in runes mode (#11321)

pull/11315/head
Rich Harris 1 year ago committed by GitHub
parent 476f2172b6
commit 6eb70f88bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: remove `bind_prop` in runes mode

@ -232,18 +232,6 @@ export function client_component(source, analysis, options) {
group_binding_declarations.push(b.const(group.name, b.array([])));
}
// Bind static exports to props so that people can access them with bind:x
const static_bindings = analysis.exports.map(({ name, alias }) => {
return b.stmt(
b.call(
'$.bind_prop',
b.id('$$props'),
b.literal(alias ?? name),
serialize_get_binding(b.id(name), instance_state)
)
);
});
const component_returned_object = analysis.exports.map(({ name, alias }) => {
const expression = serialize_get_binding(b.id(name), instance_state);
@ -369,10 +357,25 @@ export function client_component(source, analysis, options) {
...group_binding_declarations,
.../** @type {import('estree').Statement[]} */ (instance.body),
analysis.runes ? b.empty : b.stmt(b.call('$.init')),
.../** @type {import('estree').Statement[]} */ (template.body),
...static_bindings
.../** @type {import('estree').Statement[]} */ (template.body)
]);
if (!analysis.runes) {
// Bind static exports to props so that people can access them with bind:x
for (const { name, alias } of analysis.exports) {
component_block.body.push(
b.stmt(
b.call(
'$.bind_prop',
b.id('$$props'),
b.literal(alias ?? name),
serialize_get_binding(b.id(name), instance_state)
)
)
);
}
}
const append_styles =
analysis.inject_styles && analysis.css.ast
? () =>

Loading…
Cancel
Save