File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,11 @@ const addDynamicVariablesToElements = (
5454 cssVar : CssVariables
5555) : void => {
5656 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+ ) {
6062 addDynamicVariablesToElements ( processor , childNode , cssVar ) ;
6163 } else if ( childNode . type === 'Element' ) {
6264 const attributesLength = childNode . attributes . length ;
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ describe('Bind variable to CSS', () => {
152152 ) ;
153153 } ) ;
154154
155- test ( 'root elements has `each` statement' , async ( ) => {
155+ test ( 'root element has `each` statement' , async ( ) => {
156156 const output = await compiler ( {
157157 source : `${ script } ` +
158158 `{#await promise}` +
@@ -183,4 +183,22 @@ describe('Bind variable to CSS', () => {
183183 `{/await}<style module>:global(div){color:var(--color-123)}</style>`
184184 ) ;
185185 } ) ;
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+ } ) ;
186204} ) ;
You can’t perform that action at this time.
0 commit comments