@@ -22,14 +22,17 @@ test('container#prepend', (t) => {
2222
2323test ( 'container#each' , ( t ) => {
2424 let str = '' ;
25+ let indexes = [ ] ;
2526 parse ( 'h1, h2:not(h3, h4)' , ( selectors ) => {
26- selectors . each ( ( selector ) => {
27+ selectors . each ( ( selector , index ) => {
2728 if ( selector . first . type === 'tag' ) {
2829 str += selector . first . value ;
2930 }
31+ indexes . push ( index ) ;
3032 } ) ;
3133 } ) ;
3234 t . deepEqual ( str , 'h1h2' ) ;
35+ t . deepEqual ( indexes , [ 0 , 1 ] ) ;
3336} ) ;
3437
3538test ( 'container#each (safe iteration)' , ( t ) => {
@@ -63,14 +66,17 @@ test('container#each (early exit)', (t) => {
6366
6467test ( 'container#walk' , ( t ) => {
6568 let str = '' ;
69+ let indexes = [ ] ;
6670 parse ( 'h1, h2:not(h3, h4)' , ( selectors ) => {
67- selectors . walk ( ( selector ) => {
71+ selectors . walk ( ( selector , index ) => {
6872 if ( selector . type === 'tag' ) {
6973 str += selector . value ;
74+ indexes . push ( index ) ;
7075 }
7176 } ) ;
7277 } ) ;
7378 t . deepEqual ( str , 'h1h2h3h4' ) ;
79+ t . deepEqual ( indexes , [ 0 , 0 , 0 , 0 ] ) ;
7480} ) ;
7581
7682test ( 'container#walk (safe iteration)' , ( t ) => {
0 commit comments