@@ -5,6 +5,7 @@ import { DomGenerator } from '../../index';
5
5
import Block from '../../Block' ;
6
6
import { Node } from '../../../../interfaces' ;
7
7
import { State } from '../../interfaces' ;
8
+ import getObject from '../../../../utils/getObject' ;
8
9
9
10
export default function visitBinding (
10
11
generator : DomGenerator ,
@@ -14,16 +15,11 @@ export default function visitBinding(
14
15
attribute ,
15
16
local
16
17
) {
17
- const { name } = flattenReference ( attribute . value ) ;
18
+ const { name } = getObject ( attribute . value ) ;
18
19
const { snippet, contexts, dependencies } = block . contextualise (
19
20
attribute . value
20
21
) ;
21
22
22
- if ( dependencies . length > 1 )
23
- throw new Error (
24
- 'An unexpected situation arose. Please raise an issue at https://github.com/sveltejs/svelte/issues — thanks!'
25
- ) ;
26
-
27
23
contexts . forEach ( context => {
28
24
if ( ! ~ local . allUsedContexts . indexOf ( context ) )
29
25
local . allUsedContexts . push ( context ) ;
@@ -38,8 +34,9 @@ export default function visitBinding(
38
34
obj = block . listNames . get ( name ) ;
39
35
prop = block . indexNames . get ( name ) ;
40
36
} else if ( attribute . value . type === 'MemberExpression' ) {
41
- prop = `'[✂${ attribute . value . property . start } -${ attribute . value . property
42
- . end } ✂]'`;
37
+ prop = `[✂${ attribute . value . property . start } -${ attribute . value . property
38
+ . end } ✂]`;
39
+ if ( ! attribute . value . computed ) prop = `'${ prop } '` ;
43
40
obj = `[✂${ attribute . value . object . start } -${ attribute . value . object . end } ✂]` ;
44
41
} else {
45
42
obj = 'state' ;
@@ -85,7 +82,7 @@ export default function visitBinding(
85
82
local . update . addBlock ( deindent `
86
83
if ( !${ updating } && ${ dependencies
87
84
. map ( dependency => `'${ dependency } ' in changed` )
88
- . join ( '|| ' ) } ) {
85
+ . join ( ' || ' ) } ) {
89
86
${ updating } = true;
90
87
${ local . name } ._set({ ${ attribute . name } : ${ snippet } });
91
88
${ updating } = false;
0 commit comments