@@ -173,11 +173,18 @@ export class Each extends DataComponent {
173173 currentNode : NodeType ,
174174 indexData : any ,
175175 eachIndex : number ,
176- importData : any
176+ importData : any ,
177+ oldData : any
177178 ) => {
178- const { values, nodes, stack } = currentNode ;
179- for ( let i = 0 ; i < values . length ; i ++ ) {
180- const value = values [ i ] ;
179+ const { values, nodes, stack, valuesImport } = currentNode ;
180+ if ( oldData [ eachIndex ] !== indexData ) {
181+ for ( let i = 0 ; i < values . length ; i ++ ) {
182+ const value = values [ i ] ;
183+ value ( nodes , stack , indexData , importData , eachIndex , value ) ;
184+ }
185+ }
186+ for ( let i = 0 ; i < ( valuesImport as any ) . length ; i ++ ) {
187+ const value = ( valuesImport as any ) [ i ] ;
181188 value ( nodes , stack , indexData , importData , eachIndex , value ) ;
182189 }
183190 } ;
@@ -303,7 +310,8 @@ export class Each extends DataComponent {
303310 oldNodes [ oldFirstIndex ] ,
304311 data [ newFirstIndex ] ,
305312 newFirstIndex ,
306- importData
313+ importData ,
314+ oldData
307315 ) ;
308316 newData [ newFirstIndex ++ ] = oldNodes [ oldFirstIndex ++ ] ;
309317 continue ;
@@ -323,7 +331,8 @@ export class Each extends DataComponent {
323331 oldNodes [ currentOldLastIndex ] ,
324332 data [ currentNewLastIndex ] ,
325333 currentNewLastIndex ,
326- importData
334+ importData ,
335+ oldData
327336 ) ;
328337 newData [ currentNewLastIndex ] = oldNodes [ currentOldLastIndex ] ;
329338 if (
@@ -344,13 +353,15 @@ export class Each extends DataComponent {
344353 oldNodes [ currentOldLastIndex ] ,
345354 data [ newFirstIndex ] ,
346355 newFirstIndex ,
347- importData
356+ importData ,
357+ oldData
348358 ) ;
349359 renderValuesNode (
350360 oldNodes [ oldFirstIndex ] ,
351361 data [ currentNewLastIndex ] ,
352362 currentNewLastIndex ,
353- importData
363+ importData ,
364+ oldData
354365 ) ;
355366 const el1 = ( newData [ newFirstIndex ] =
356367 oldNodes [ currentOldLastIndex ] ) . el as Element ;
@@ -460,7 +471,8 @@ export class Each extends DataComponent {
460471 oldNodes [ oldFirstIndex ] ,
461472 data [ newFirstIndex ] ,
462473 newFirstIndex ,
463- importData
474+ importData ,
475+ oldData
464476 ) ;
465477 newData [ newFirstIndex ] = oldNodes [ oldFirstIndex ++ ] ;
466478 if (
@@ -486,7 +498,8 @@ export class Each extends DataComponent {
486498 oldNodes [ currentOldLastIndex ] ,
487499 data [ currentNewLastIndex ] ,
488500 currentNewLastIndex ,
489- importData
501+ importData ,
502+ oldData
490503 ) ;
491504 newData [ currentNewLastIndex ] =
492505 oldNodes [ currentOldLastIndex ] ;
@@ -508,13 +521,15 @@ export class Each extends DataComponent {
508521 oldNodes [ currentOldLastIndex ] ,
509522 data [ newFirstIndex ] ,
510523 newFirstIndex ,
511- importData
524+ importData ,
525+ oldData
512526 ) ;
513527 renderValuesNode (
514528 oldNodes [ oldFirstIndex ] ,
515529 data [ currentNewLastIndex ] ,
516530 currentNewLastIndex ,
517- importData
531+ importData ,
532+ oldData
518533 ) ;
519534 const el1 = ( newData [ newFirstIndex ] =
520535 oldNodes [ currentOldLastIndex ] ) . el as Element ;
@@ -541,7 +556,8 @@ export class Each extends DataComponent {
541556 newData [ newFirstIndex ] ,
542557 data [ newFirstIndex ] ,
543558 newFirstIndex ++ ,
544- importData
559+ importData ,
560+ oldData
545561 ) ;
546562 oldNodes [ currentIndex ] = undefined as unknown as NodeType ;
547563 continue ;
0 commit comments