@@ -258,6 +258,9 @@ export class Interpreter {
258258
259259 const value = await this . _eval ( node . expr , nsScope , [ ] ) ;
260260 assertValue ( value ) ;
261+
262+ await this . evalAndSetAttr ( node . attr , value , scope , [ ] ) ;
263+
261264 if (
262265 node . expr . type === 'fn'
263266 && isFunction ( value )
@@ -302,6 +305,9 @@ export class Interpreter {
302305
303306 const value = this . _evalSync ( node . expr , nsScope , [ ] ) ;
304307 assertValue ( value ) ;
308+
309+ this . evalAndSetAttrSync ( node . attr , value , scope , [ ] ) ;
310+
305311 if (
306312 node . expr . type === 'fn'
307313 && isFunction ( value )
@@ -648,18 +654,7 @@ export class Interpreter {
648654 if ( isControl ( value ) ) {
649655 return value ;
650656 }
651- if ( node . attr . length > 0 ) {
652- const attrs : Value [ 'attr' ] = [ ] ;
653- for ( const nAttr of node . attr ) {
654- const value = await this . _eval ( nAttr . value , scope , callStack ) ;
655- assertValue ( value ) ;
656- attrs . push ( {
657- name : nAttr . name ,
658- value,
659- } ) ;
660- }
661- value . attr = attrs ;
662- }
657+ await this . evalAndSetAttr ( node . attr , value , scope , callStack ) ;
663658 if (
664659 node . expr . type === 'fn'
665660 && node . dest . type === 'identifier'
@@ -1192,18 +1187,7 @@ export class Interpreter {
11921187 if ( isControl ( value ) ) {
11931188 return value ;
11941189 }
1195- if ( node . attr . length > 0 ) {
1196- const attrs : Value [ 'attr' ] = [ ] ;
1197- for ( const nAttr of node . attr ) {
1198- const value = this . _evalSync ( nAttr . value , scope , callStack ) ;
1199- assertValue ( value ) ;
1200- attrs . push ( {
1201- name : nAttr . name ,
1202- value,
1203- } ) ;
1204- }
1205- value . attr = attrs ;
1206- }
1190+ this . evalAndSetAttrSync ( node . attr , value , scope , callStack ) ;
12071191 if (
12081192 node . expr . type === 'fn'
12091193 && node . dest . type === 'identifier'
@@ -1666,6 +1650,38 @@ export class Interpreter {
16661650 this . unpauseHandlers = [ ] ;
16671651 }
16681652
1653+ @autobind
1654+ private async evalAndSetAttr ( attr : Ast . Attribute [ ] , value : Value , scope : Scope , callStack : readonly CallInfo [ ] ) : Promise < void > {
1655+ if ( attr . length > 0 ) {
1656+ const attrs : Value [ 'attr' ] = [ ] ;
1657+ for ( const nAttr of attr ) {
1658+ const value = await this . _eval ( nAttr . value , scope , callStack ) ;
1659+ assertValue ( value ) ;
1660+ attrs . push ( {
1661+ name : nAttr . name ,
1662+ value,
1663+ } ) ;
1664+ }
1665+ value . attr = attrs ;
1666+ }
1667+ }
1668+
1669+ @autobind
1670+ private evalAndSetAttrSync ( attr : Ast . Attribute [ ] , value : Value , scope : Scope , callStack : readonly CallInfo [ ] ) : void {
1671+ if ( attr . length > 0 ) {
1672+ const attrs : Value [ 'attr' ] = [ ] ;
1673+ for ( const nAttr of attr ) {
1674+ const value = this . _evalSync ( nAttr . value , scope , callStack ) ;
1675+ assertValue ( value ) ;
1676+ attrs . push ( {
1677+ name : nAttr . name ,
1678+ value,
1679+ } ) ;
1680+ }
1681+ value . attr = attrs ;
1682+ }
1683+ }
1684+
16691685 @autobind
16701686 private define ( scope : Scope , dest : Ast . Expression , value : Value , isMutable : boolean ) : void {
16711687 switch ( dest . type ) {
0 commit comments