File tree 2 files changed +24
-4
lines changed
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,11 @@ const addDynamicVariablesToElements = (
54
54
cssVar : CssVariables
55
55
) : void => {
56
56
node . children ?. forEach ( ( childNode ) => {
57
- // console.log(childNode);
58
-
59
- if ( childNode . type === 'InlineComponent' || childNode . type === 'EachBlock' ) {
57
+ if (
58
+ childNode . type === 'InlineComponent' ||
59
+ childNode . type === 'EachBlock' ||
60
+ childNode . type === 'KeyBlock'
61
+ ) {
60
62
addDynamicVariablesToElements ( processor , childNode , cssVar ) ;
61
63
} else if ( childNode . type === 'Element' ) {
62
64
const attributesLength = childNode . attributes . length ;
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ describe('Bind variable to CSS', () => {
152
152
) ;
153
153
} ) ;
154
154
155
- test ( 'root elements has `each` statement' , async ( ) => {
155
+ test ( 'root element has `each` statement' , async ( ) => {
156
156
const output = await compiler ( {
157
157
source : `${ script } ` +
158
158
`{#await promise}` +
@@ -183,4 +183,22 @@ describe('Bind variable to CSS', () => {
183
183
`{/await}<style module>:global(div){color:var(--color-123)}</style>`
184
184
) ;
185
185
} ) ;
186
+
187
+ test ( 'root element has `key` statement' , async ( ) => {
188
+ const output = await compiler ( {
189
+ source : `${ script } ` +
190
+ `{#key value}` +
191
+ `<div transition:fade>{value}</div>` +
192
+ `{/key}<style module>div{color:bind(color)}</style>` ,
193
+ } , {
194
+ cssVariableHash : '123' ,
195
+ } ) ;
196
+
197
+ expect ( output ) . toBe (
198
+ `${ script } ` +
199
+ `{#key value}` +
200
+ `<div transition:fade style="--color-123:{color};">{value}</div>` +
201
+ `{/key}<style module>:global(div){color:var(--color-123)}</style>`
202
+ ) ;
203
+ } ) ;
186
204
} ) ;
You can’t perform that action at this time.
0 commit comments