Skip to content

Commit 4c3c658

Browse files
committed
fix bind:group
1 parent 805ca34 commit 4c3c658

File tree

1 file changed

+36
-39
lines changed

1 file changed

+36
-39
lines changed

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

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,57 @@ import { init_spread_bindings } from '../../shared/spread_bindings.js';
1414
* @param {ComponentContext} context
1515
*/
1616
export function BindDirective(node, context) {
17+
const expression = /** @type {Expression} */ (context.visit(node.expression));
18+
const property = binding_properties[node.name];
19+
20+
const parent = /** @type {AST.SvelteNode} */ (context.path.at(-1));
21+
1722
let get, set;
1823

1924
// Handle SpreadElement by creating a variable declaration before visiting
2025
if (node.expression.type === 'SpreadElement') {
2126
const { get: getter, set: setter } = init_spread_bindings(node.expression, context);
2227
get = getter;
2328
set = setter;
29+
} else if (expression.type === 'SequenceExpression') {
30+
[get, set] = expression.expressions;
2431
} else {
25-
const expression = /** @type {Expression} */ (context.visit(node.expression));
26-
27-
if (expression.type === 'SequenceExpression') {
28-
[get, set] = expression.expressions;
29-
} else {
30-
if (
31-
dev &&
32-
context.state.analysis.runes &&
33-
expression.type === 'MemberExpression' &&
34-
(node.name !== 'this' ||
35-
context.path.some(
36-
({ type }) =>
37-
type === 'IfBlock' ||
38-
type === 'EachBlock' ||
39-
type === 'AwaitBlock' ||
40-
type === 'KeyBlock'
41-
)) &&
42-
!is_ignored(node, 'binding_property_non_reactive')
43-
) {
44-
validate_binding(context.state, node, expression);
45-
}
32+
if (
33+
dev &&
34+
context.state.analysis.runes &&
35+
expression.type === 'MemberExpression' &&
36+
(node.name !== 'this' ||
37+
context.path.some(
38+
({ type }) =>
39+
type === 'IfBlock' ||
40+
type === 'EachBlock' ||
41+
type === 'AwaitBlock' ||
42+
type === 'KeyBlock'
43+
)) &&
44+
!is_ignored(node, 'binding_property_non_reactive')
45+
) {
46+
validate_binding(context.state, node, expression);
47+
}
4648

47-
get = b.thunk(expression);
49+
get = b.thunk(expression);
4850

49-
/** @type {Expression | undefined} */
50-
set = b.unthunk(
51-
b.arrow(
52-
[b.id('$$value')],
53-
/** @type {Expression} */ (
54-
context.visit(
55-
b.assignment('=', /** @type {Pattern} */ (node.expression), b.id('$$value'))
56-
)
51+
/** @type {Expression | undefined} */
52+
set = b.unthunk(
53+
b.arrow(
54+
[b.id('$$value')],
55+
/** @type {Expression} */ (
56+
context.visit(
57+
b.assignment('=', /** @type {Pattern} */ (node.expression), b.id('$$value'))
5758
)
5859
)
59-
);
60+
)
61+
);
6062

61-
if (get === set) {
62-
set = undefined;
63-
}
63+
if (get === set) {
64+
set = undefined;
6465
}
6566
}
6667

67-
const property = binding_properties[node.name];
68-
69-
const parent = /** @type {AST.SvelteNode} */ (context.path.at(-1));
70-
7168
/** @type {CallExpression} */
7269
let call;
7370

@@ -231,7 +228,7 @@ export function BindDirective(node, context) {
231228

232229
if (value !== undefined) {
233230
group_getter = b.thunk(
234-
b.block([b.stmt(build_attribute_value(value, context).value), b.return(get)])
231+
b.block([b.stmt(build_attribute_value(value, context).value), b.return(b.call(get))])
235232
);
236233
}
237234
}

0 commit comments

Comments
 (0)