11import { array , hole } from './handler.js' ;
2- import { cache as newCache } from './literals.js' ;
3- import { empty } from './utils.js' ;
2+ import { cache } from './literals.js' ;
43import create from './creator.js' ;
54import parser from './parser.js' ;
65
@@ -10,14 +9,14 @@ const parseHTML = create(parser(false));
109const parseSVG = create ( parser ( true ) ) ;
1110
1211/**
13- * @param {import("./literals.js").Cache } cache
12+ * @param {import("./literals.js").Cache } info
1413 * @param {Hole } hole
1514 * @returns {Node }
1615 */
17- const unroll = ( cache , { s, t, v } ) => {
18- if ( cache . t !== t )
19- assign ( cache , ( s ? parseSVG : parseHTML ) ( t , v ) ) ;
20- for ( let { d, s } = cache , i = 0 ; i < d . length ; i ++ ) {
16+ const unroll = ( info , { s, t, v } ) => {
17+ if ( info . t !== t )
18+ assign ( info , ( s ? parseSVG : parseHTML ) ( t , v ) ) ;
19+ for ( let { d, s } = info , i = 0 ; i < d . length ; i ++ ) {
2120 const value = v [ i ] ;
2221 const detail = d [ i ] ;
2322 const { v : previous , u : update , t : target , n : name } = detail ;
@@ -31,7 +30,7 @@ const unroll = (cache, { s, t, v }) => {
3130 break ;
3231 case hole :
3332 const current = value instanceof Hole ?
34- unroll ( s [ i ] || ( s [ i ] = newCache ( empty ) ) , value ) :
33+ unroll ( s [ i ] || ( s [ i ] = cache ( ) ) , value ) :
3534 ( s [ i ] = null , value )
3635 ;
3736 if ( current !== previous )
@@ -43,22 +42,22 @@ const unroll = (cache, { s, t, v }) => {
4342 break ;
4443 }
4544 }
46- return cache . n ;
45+ return info . n ;
4746} ;
4847
4948/**
5049 * @param {Cache } cache
5150 * @param {any[] } values
5251 * @returns {number }
5352 */
54- const unrollValues = ( { s : stack } , values ) => {
53+ const unrollValues = ( stack , values ) => {
5554 let i = 0 , { length } = values ;
5655 if ( length < stack . length ) stack . splice ( length ) ;
5756 for ( ; i < length ; i ++ ) {
5857 const value = values [ i ] ;
59- const asHole = value instanceof Hole ;
60- const cache = stack [ i ] || ( stack [ i ] = asHole ? newCache ( empty ) : null ) ;
61- if ( asHole ) values [ i ] = unroll ( cache , value ) ;
58+ if ( value instanceof Hole )
59+ values [ i ] = unroll ( stack [ i ] || ( stack [ i ] = cache ( ) ) , value ) ;
60+ else stack [ i ] = null ;
6261 }
6362 return values ;
6463} ;
@@ -76,7 +75,7 @@ export class Hole {
7675 this . t = template ;
7776 this . v = values ;
7877 }
79- toDOM ( cache = newCache ( empty ) ) {
80- return unroll ( cache , this ) ;
78+ toDOM ( info = cache ( ) ) {
79+ return unroll ( info , this ) ;
8180 }
8281} ;
0 commit comments