@ -5,7 +5,7 @@ import AbstractBlock from './shared/AbstractBlock';
import Element from './Element' ;
import Element from './Element' ;
import ConstTag from './ConstTag' ;
import ConstTag from './ConstTag' ;
import { Context , unpack_destructuring } from './shared/Context' ;
import { Context , unpack_destructuring } from './shared/Context' ;
import { Node } from 'estree' ;
import { Node , Identifier } from 'estree' ;
import Component from '../Component' ;
import Component from '../Component' ;
import { TemplateNode } from '../../interfaces' ;
import { TemplateNode } from '../../interfaces' ;
import compiler_errors from '../compiler_errors' ;
import compiler_errors from '../compiler_errors' ;
@ -28,7 +28,7 @@ export default class EachBlock extends AbstractBlock {
has_animation : boolean ;
has_animation : boolean ;
has_binding = false ;
has_binding = false ;
has_index_binding = false ;
has_index_binding = false ;
context_rest_properties : Map < string , Node > ;
else ? : ElseBlock ;
else ? : ElseBlock ;
constructor ( component : Component , parent : Node , scope : TemplateScope , info : TemplateNode ) {
constructor ( component : Component , parent : Node , scope : TemplateScope , info : TemplateNode ) {
@ -40,10 +40,17 @@ export default class EachBlock extends AbstractBlock {
this . index = info . index ;
this . index = info . index ;
this . scope = scope . child ( ) ;
this . scope = scope . child ( ) ;
this . context_rest_properties = new Map ( ) ;
this . contexts = [ ] ;
this . contexts = [ ] ;
unpack_destructuring ( { contexts : this.contexts , node : info.context , scope , component } ) ;
unpack_destructuring ( { contexts : this.contexts , node : info.context , scope , component } ) ;
if ( this . context_node . type === 'ObjectPattern' ) {
this . context_node . properties . forEach ( i = > {
if ( i . type === 'RestElement' ) {
this . context_rest_properties . set ( ( i . argument as Identifier ) . name , i ) ;
}
} ) ;
}
this . contexts . forEach ( context = > {
this . contexts . forEach ( context = > {
this . scope . add ( context . key . name , this . expression . dependencies , this ) ;
this . scope . add ( context . key . name , this . expression . dependencies , this ) ;
} ) ;
} ) ;