@@ -14,60 +14,57 @@ import { init_spread_bindings } from '../../shared/spread_bindings.js';
14
14
* @param {ComponentContext } context
15
15
*/
16
16
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
+
17
22
let get , set ;
18
23
19
24
// Handle SpreadElement by creating a variable declaration before visiting
20
25
if ( node . expression . type === 'SpreadElement' ) {
21
26
const { get : getter , set : setter } = init_spread_bindings ( node . expression , context ) ;
22
27
get = getter ;
23
28
set = setter ;
29
+ } else if ( expression . type === 'SequenceExpression' ) {
30
+ [ get , set ] = expression . expressions ;
24
31
} 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
+ }
46
48
47
- get = b . thunk ( expression ) ;
49
+ get = b . thunk ( expression ) ;
48
50
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' ) )
57
58
)
58
59
)
59
- ) ;
60
+ )
61
+ ) ;
60
62
61
- if ( get === set ) {
62
- set = undefined ;
63
- }
63
+ if ( get === set ) {
64
+ set = undefined ;
64
65
}
65
66
}
66
67
67
- const property = binding_properties [ node . name ] ;
68
-
69
- const parent = /** @type {AST.SvelteNode } */ ( context . path . at ( - 1 ) ) ;
70
-
71
68
/** @type {CallExpression } */
72
69
let call ;
73
70
@@ -231,7 +228,7 @@ export function BindDirective(node, context) {
231
228
232
229
if ( value !== undefined ) {
233
230
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 ) ) ] )
235
232
) ;
236
233
}
237
234
}
0 commit comments