@@ -16,8 +16,8 @@ import { build_template_chunk } from './utils.js';
1616 * @param {boolean } is_element
1717 * @param {ComponentContext } context
1818 */
19- export function process_children ( nodes , initial , is_element , { visit , state } ) {
20- const within_bound_contenteditable = state . metadata . bound_contenteditable ;
19+ export function process_children ( nodes , initial , is_element , context ) {
20+ const within_bound_contenteditable = context . state . metadata . bound_contenteditable ;
2121 let prev = initial ;
2222 let skipped = 0 ;
2323
@@ -48,8 +48,8 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
4848 let id = expression ;
4949
5050 if ( id . type !== 'Identifier' ) {
51- id = b . id ( state . scope . generate ( name ) ) ;
52- state . init . push ( b . var ( id , expression ) ) ;
51+ id = b . id ( context . state . scope . generate ( name ) ) ;
52+ context . state . init . push ( b . var ( id , expression ) ) ;
5353 }
5454
5555 prev = ( ) => id ;
@@ -64,13 +64,13 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
6464 function flush_sequence ( sequence ) {
6565 if ( sequence . every ( ( node ) => node . type === 'Text' ) ) {
6666 skipped += 1 ;
67- state . template . push_text ( sequence ) ;
67+ context . state . template . push_text ( sequence ) ;
6868 return ;
6969 }
7070
71- state . template . push_text ( [ { type : 'Text' , data : ' ' , raw : ' ' , start : - 1 , end : - 1 } ] ) ;
71+ context . state . template . push_text ( [ { type : 'Text' , data : ' ' , raw : ' ' , start : - 1 , end : - 1 } ] ) ;
7272
73- const { has_state, value } = build_template_chunk ( sequence , visit , state ) ;
73+ const { has_state, value } = build_template_chunk ( sequence , context ) ;
7474
7575 // if this is a standalone `{expression}`, make sure we handle the case where
7676 // no text node was created because the expression was empty during SSR
@@ -80,9 +80,9 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
8080 const update = b . stmt ( b . call ( '$.set_text' , id , value ) ) ;
8181
8282 if ( has_state && ! within_bound_contenteditable ) {
83- state . update . push ( update ) ;
83+ context . state . update . push ( update ) ;
8484 } else {
85- state . init . push ( b . stmt ( b . assignment ( '=' , b . member ( id , 'nodeValue' ) , value ) ) ) ;
85+ context . state . init . push ( b . stmt ( b . assignment ( '=' , b . member ( id , 'nodeValue' ) , value ) ) ) ;
8686 }
8787 }
8888
@@ -95,18 +95,18 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
9595 sequence = [ ] ;
9696 }
9797
98- let child_state = state ;
98+ let child_state = context . state ;
9999
100- if ( is_static_element ( node , state ) ) {
100+ if ( is_static_element ( node , context . state ) ) {
101101 skipped += 1 ;
102102 } else if ( node . type === 'EachBlock' && nodes . length === 1 && is_element ) {
103103 node . metadata . is_controlled = true ;
104104 } else {
105105 const id = flush_node ( false , node . type === 'RegularElement' ? node . name : 'node' ) ;
106- child_state = { ...state , node : id } ;
106+ child_state = { ...context . state , node : id } ;
107107 }
108108
109- visit ( node , child_state ) ;
109+ context . visit ( node , child_state ) ;
110110 }
111111 }
112112
@@ -118,7 +118,7 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
118118 // traverse to the last (n - 1) one when hydrating
119119 if ( skipped > 1 ) {
120120 skipped -= 1 ;
121- state . init . push ( b . stmt ( b . call ( '$.next' , skipped !== 1 && b . literal ( skipped ) ) ) ) ;
121+ context . state . init . push ( b . stmt ( b . call ( '$.next' , skipped !== 1 && b . literal ( skipped ) ) ) ) ;
122122 }
123123}
124124
0 commit comments