@ -33,7 +33,7 @@ export default function visitEachBlock(
generator . code . overwrite ( c , c + 4 , 'length' ) ;
generator . code . overwrite ( c , c + 4 , 'length' ) ;
const length = ` [✂ ${ c } - ${ c + 4 } ✂] ` ;
const length = ` [✂ ${ c } - ${ c + 4 } ✂] ` ;
const mountOrIntro = node . _block . hasIntroMethod ? 'i ntro ' : 'm ount ';
const mountOrIntro = node . _block . hasIntroMethod ? 'i ' : 'm ';
const vars = {
const vars = {
each ,
each ,
create_each_block ,
create_each_block ,
@ -75,7 +75,7 @@ export default function visitEachBlock(
block . builders . init . addBlock ( deindent `
block . builders . init . addBlock ( deindent `
if ( ! $ { each_block_value } . $ { length } ) {
if ( ! $ { each_block_value } . $ { length } ) {
$ { each_block_else } = $ { node . else . _block . name } ( $ { params } , # component ) ;
$ { each_block_else } = $ { node . else . _block . name } ( $ { params } , # component ) ;
$ { each_block_else } . c reate ( ) ;
$ { each_block_else } . c ( ) ;
}
}
` );
` );
@ -90,14 +90,14 @@ export default function visitEachBlock(
if ( node . else . _block . hasUpdateMethod ) {
if ( node . else . _block . hasUpdateMethod ) {
block . builders . update . addBlock ( deindent `
block . builders . update . addBlock ( deindent `
if ( ! $ { each_block_value } . $ { length } && $ { each_block_else } ) {
if ( ! $ { each_block_value } . $ { length } && $ { each_block_else } ) {
$ { each_block_else } . u pdate ( changed , $ { params } ) ;
$ { each_block_else } . p( changed , $ { params } ) ;
} else if ( ! $ { each_block_value } . $ { length } ) {
} else if ( ! $ { each_block_value } . $ { length } ) {
$ { each_block_else } = $ { node . else . _block . name } ( $ { params } , # component ) ;
$ { each_block_else } = $ { node . else . _block . name } ( $ { params } , # component ) ;
$ { each_block_else } . c reate ( ) ;
$ { each_block_else } . c ( ) ;
$ { each_block_else } . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
$ { each_block_else } . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
} else if ( $ { each_block_else } ) {
} else if ( $ { each_block_else } ) {
$ { each_block_else } . u nmount ( ) ;
$ { each_block_else } . u ( ) ;
$ { each_block_else } . d estroy ( ) ;
$ { each_block_else } . d ( ) ;
$ { each_block_else } = null ;
$ { each_block_else } = null ;
}
}
` );
` );
@ -105,24 +105,24 @@ export default function visitEachBlock(
block . builders . update . addBlock ( deindent `
block . builders . update . addBlock ( deindent `
if ( $ { each_block_value } . $ { length } ) {
if ( $ { each_block_value } . $ { length } ) {
if ( $ { each_block_else } ) {
if ( $ { each_block_else } ) {
$ { each_block_else } . u nmount ( ) ;
$ { each_block_else } . u ( ) ;
$ { each_block_else } . d estroy ( ) ;
$ { each_block_else } . d ( ) ;
$ { each_block_else } = null ;
$ { each_block_else } = null ;
}
}
} else if ( ! $ { each_block_else } ) {
} else if ( ! $ { each_block_else } ) {
$ { each_block_else } = $ { node . else . _block . name } ( $ { params } , # component ) ;
$ { each_block_else } = $ { node . else . _block . name } ( $ { params } , # component ) ;
$ { each_block_else } . c reate ( ) ;
$ { each_block_else } . c ( ) ;
$ { each_block_else } . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
$ { each_block_else } . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
}
}
` );
` );
}
}
block . builders . unmount . addLine (
block . builders . unmount . addLine (
` if ( ${ each_block_else } ) ${ each_block_else } .u nmount ()`
` if ( ${ each_block_else } ) ${ each_block_else } .u ()`
) ;
) ;
block . builders . destroy . addBlock ( deindent `
block . builders . destroy . addBlock ( deindent `
if ( $ { each_block_else } ) $ { each_block_else } . d estroy ( ) ;
if ( $ { each_block_else } ) $ { each_block_else } . d ( ) ;
` );
` );
}
}
@ -196,7 +196,7 @@ function keyed(
block . builders . create . addBlock ( deindent `
block . builders . create . addBlock ( deindent `
var $ { iteration } = $ { head } ;
var $ { iteration } = $ { head } ;
while ( $ { iteration } ) {
while ( $ { iteration } ) {
$ { iteration } . c reate ( ) ;
$ { iteration } . c ( ) ;
$ { iteration } = $ { iteration } . next ;
$ { iteration } = $ { iteration } . next ;
}
}
` );
` );
@ -204,7 +204,7 @@ function keyed(
block . builders . claim . addBlock ( deindent `
block . builders . claim . addBlock ( deindent `
var $ { iteration } = $ { head } ;
var $ { iteration } = $ { head } ;
while ( $ { iteration } ) {
while ( $ { iteration } ) {
$ { iteration } . c laim ( $ { state . parentNodes } ) ;
$ { iteration } . l( $ { state . parentNodes } ) ;
$ { iteration } = $ { iteration } . next ;
$ { iteration } = $ { iteration } . next ;
}
}
` );
` );
@ -225,9 +225,9 @@ function keyed(
const fn = block . getUniqueName ( ` ${ each } _outro ` ) ;
const fn = block . getUniqueName ( ` ${ each } _outro ` ) ;
block . builders . init . addBlock ( deindent `
block . builders . init . addBlock ( deindent `
function $ { fn } ( iteration ) {
function $ { fn } ( iteration ) {
iteration . o utro ( function ( ) {
iteration . o ( function ( ) {
iteration . u nmount ( ) ;
iteration . u ( ) ;
iteration . d estroy ( ) ;
iteration . d ( ) ;
$ { lookup } [ iteration . key ] = null ;
$ { lookup } [ iteration . key ] = null ;
} ) ;
} ) ;
}
}
@ -249,8 +249,8 @@ function keyed(
const fn = block . getUniqueName ( ` ${ each } _destroy ` ) ;
const fn = block . getUniqueName ( ` ${ each } _destroy ` ) ;
block . builders . init . addBlock ( deindent `
block . builders . init . addBlock ( deindent `
function $ { fn } ( iteration ) {
function $ { fn } ( iteration ) {
iteration . u nmount ( ) ;
iteration . u ( ) ;
iteration . d estroy ( ) ;
iteration . d ( ) ;
$ { lookup } [ iteration . key ] = null ;
$ { lookup } [ iteration . key ] = null ;
}
}
` );
` );
@ -283,7 +283,7 @@ function keyed(
var $ { iteration } = $ { lookup } [ $ { key } ] ;
var $ { iteration } = $ { lookup } [ $ { key } ] ;
$ { dynamic &&
$ { dynamic &&
` if ( ${ iteration } ) ${ iteration } . u pdate (changed, ${ params } , ${ each_block_value } , ${ each_block_value } [#i], #i); ` }
` if ( ${ iteration } ) ${ iteration } . p(changed, ${ params } , ${ each_block_value } , ${ each_block_value } [#i], #i); ` }
if ( $ { expected } ) {
if ( $ { expected } ) {
if ( $ { key } === $ { expected } . key ) {
if ( $ { key } === $ { expected } . key ) {
@ -301,11 +301,11 @@ function keyed(
$ { iteration } . discard = false ;
$ { iteration } . discard = false ;
$ { iteration } . last = $ { last } ;
$ { iteration } . last = $ { last } ;
if ( ! $ { expected } ) $ { iteration } . m ount ( $ { parentNode } , $ { anchor } ) ;
if ( ! $ { expected } ) $ { iteration } . m ( $ { parentNode } , $ { anchor } ) ;
} else {
} else {
// key is being inserted
// key is being inserted
$ { iteration } = $ { lookup } [ $ { key } ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component , $ { key } ) ;
$ { iteration } = $ { lookup } [ $ { key } ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component , $ { key } ) ;
$ { iteration } . c reate ( ) ;
$ { iteration } . c ( ) ;
$ { iteration } . $ { mountOrIntro } ( $ { parentNode } , $ { expected } . first ) ;
$ { iteration } . $ { mountOrIntro } ( $ { parentNode } , $ { expected } . first ) ;
$ { expected } . last = $ { iteration } ;
$ { expected } . last = $ { iteration } ;
@ -317,17 +317,17 @@ function keyed(
if ( $ { iteration } ) {
if ( $ { iteration } ) {
$ { iteration } . discard = false ;
$ { iteration } . discard = false ;
$ { iteration } . next = null ;
$ { iteration } . next = null ;
$ { iteration } . m ount ( $ { parentNode } , $ { anchor } ) ;
$ { iteration } . m ( $ { parentNode } , $ { anchor } ) ;
} else {
} else {
$ { iteration } = $ { lookup } [ $ { key } ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component , $ { key } ) ;
$ { iteration } = $ { lookup } [ $ { key } ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component , $ { key } ) ;
$ { iteration } . c reate ( ) ;
$ { iteration } . c ( ) ;
$ { iteration } . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
$ { iteration } . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
}
}
}
}
if ( $ { last } ) $ { last } . next = $ { iteration } ;
if ( $ { last } ) $ { last } . next = $ { iteration } ;
$ { iteration } . last = $ { last } ;
$ { iteration } . last = $ { last } ;
$ { node . _block . hasIntroMethod && ` ${ iteration } .i ntro (${ parentNode } , ${ anchor } ); ` }
$ { node . _block . hasIntroMethod && ` ${ iteration } .i (${ parentNode } , ${ anchor } ); ` }
$ { last } = $ { iteration } ;
$ { last } = $ { iteration } ;
}
}
@ -342,7 +342,7 @@ function keyed(
block . builders . unmount . addBlock ( deindent `
block . builders . unmount . addBlock ( deindent `
var $ { iteration } = $ { head } ;
var $ { iteration } = $ { head } ;
while ( $ { iteration } ) {
while ( $ { iteration } ) {
$ { iteration } . u nmount ( ) ;
$ { iteration } . u ( ) ;
$ { iteration } = $ { iteration } . next ;
$ { iteration } = $ { iteration } . next ;
}
}
` );
` );
@ -351,7 +351,7 @@ function keyed(
block . builders . destroy . addBlock ( deindent `
block . builders . destroy . addBlock ( deindent `
var $ { iteration } = $ { head } ;
var $ { iteration } = $ { head } ;
while ( $ { iteration } ) {
while ( $ { iteration } ) {
$ { iteration } . d estroy ( ) ;
$ { iteration } . d ( ) ;
$ { iteration } = $ { iteration } . next ;
$ { iteration } = $ { iteration } . next ;
}
}
` );
` );
@ -386,13 +386,13 @@ function unkeyed(
block . builders . create . addBlock ( deindent `
block . builders . create . addBlock ( deindent `
for ( var # i = 0 ; # i < $ { iterations } . length ; # i += 1 ) {
for ( var # i = 0 ; # i < $ { iterations } . length ; # i += 1 ) {
$ { iterations } [ # i ] . c reate ( ) ;
$ { iterations } [ # i ] . c ( ) ;
}
}
` );
` );
block . builders . claim . addBlock ( deindent `
block . builders . claim . addBlock ( deindent `
for ( var # i = 0 ; # i < $ { iterations } . length ; # i += 1 ) {
for ( var # i = 0 ; # i < $ { iterations } . length ; # i += 1 ) {
$ { iterations } [ # i ] . c laim ( $ { state . parentNodes } ) ;
$ { iterations } [ # i ] . l( $ { state . parentNodes } ) ;
}
}
` );
` );
@ -420,25 +420,25 @@ function unkeyed(
? node . _block . hasIntroMethod
? node . _block . hasIntroMethod
? deindent `
? deindent `
if ( $ { iterations } [ # i ] ) {
if ( $ { iterations } [ # i ] ) {
$ { iterations } [ # i ] . u pdate ( changed , $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i ) ;
$ { iterations } [ # i ] . p( changed , $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i ) ;
} else {
} else {
$ { iterations } [ # i ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component ) ;
$ { iterations } [ # i ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component ) ;
$ { iterations } [ # i ] . c reate ( ) ;
$ { iterations } [ # i ] . c ( ) ;
}
}
$ { iterations } [ # i ] . i ntro ( $ { parentNode } , $ { anchor } ) ;
$ { iterations } [ # i ] . i ( $ { parentNode } , $ { anchor } ) ;
`
`
: deindent `
: deindent `
if ( $ { iterations } [ # i ] ) {
if ( $ { iterations } [ # i ] ) {
$ { iterations } [ # i ] . u pdate ( changed , $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i ) ;
$ { iterations } [ # i ] . p( changed , $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i ) ;
} else {
} else {
$ { iterations } [ # i ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component ) ;
$ { iterations } [ # i ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component ) ;
$ { iterations } [ # i ] . c reate ( ) ;
$ { iterations } [ # i ] . c ( ) ;
$ { iterations } [ # i ] . m ount ( $ { parentNode } , $ { anchor } ) ;
$ { iterations } [ # i ] . m ( $ { parentNode } , $ { anchor } ) ;
}
}
`
`
: deindent `
: deindent `
$ { iterations } [ # i ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component ) ;
$ { iterations } [ # i ] = $ { create_each_block } ( $ { params } , $ { each_block_value } , $ { each_block_value } [ # i ] , # i , # component ) ;
$ { iterations } [ # i ] . c reate ( ) ;
$ { iterations } [ # i ] . c ( ) ;
$ { iterations } [ # i ] . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
$ { iterations } [ # i ] . $ { mountOrIntro } ( $ { parentNode } , $ { anchor } ) ;
` ;
` ;
@ -449,9 +449,9 @@ function unkeyed(
? deindent `
? deindent `
function $ { outro } ( i ) {
function $ { outro } ( i ) {
if ( $ { iterations } [ i ] ) {
if ( $ { iterations } [ i ] ) {
$ { iterations } [ i ] . o utro ( function ( ) {
$ { iterations } [ i ] . o ( function ( ) {
$ { iterations } [ i ] . u nmount ( ) ;
$ { iterations } [ i ] . u ( ) ;
$ { iterations } [ i ] . d estroy ( ) ;
$ { iterations } [ i ] . d ( ) ;
$ { iterations } [ i ] = null ;
$ { iterations } [ i ] = null ;
} ) ;
} ) ;
}
}
@ -461,8 +461,8 @@ function unkeyed(
`
`
: deindent `
: deindent `
for ( ; # i < $ { iterations } . length ; # i += 1 ) {
for ( ; # i < $ { iterations } . length ; # i += 1 ) {
$ { iterations } [ # i ] . u nmount ( ) ;
$ { iterations } [ # i ] . u ( ) ;
$ { iterations } [ # i ] . d estroy ( ) ;
$ { iterations } [ # i ] . d ( ) ;
}
}
$ { iterations } . length = $ { each_block_value } . $ { length } ;
$ { iterations } . length = $ { each_block_value } . $ { length } ;
` ;
` ;
@ -482,7 +482,7 @@ function unkeyed(
block . builders . unmount . addBlock ( deindent `
block . builders . unmount . addBlock ( deindent `
for ( var # i = 0 ; # i < $ { iterations } . length ; # i += 1 ) {
for ( var # i = 0 ; # i < $ { iterations } . length ; # i += 1 ) {
$ { iterations } [ # i ] . u nmount ( ) ;
$ { iterations } [ # i ] . u ( ) ;
}
}
` );
` );