chore: improve code generation for `bind:this` in SSR mode

pull/10524/head
Rich Harris 3 years ago
parent b5628af72e
commit c644c24fab

@ -0,0 +1,5 @@
---
'svelte': patch
---
chore: improve code generation for `bind:this` in SSR mode

@ -1060,7 +1060,9 @@ const common_visitors = {
parent.type === 'SvelteComponent' ||
parent.type === 'SvelteSelf'
) {
context.state.analysis.uses_component_bindings = true;
if (node.name !== 'this') {
context.state.analysis.uses_component_bindings = true;
}
break;
} else if (is_element_node(parent)) {
break;

@ -853,7 +853,7 @@ function serialize_inline_component(node, component_name, context) {
const value = serialize_attribute_value(attribute.value, context, false, true);
push_prop(b.prop('init', b.key(attribute.name), value));
} else if (attribute.type === 'BindDirective') {
} 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, [

Loading…
Cancel
Save