I put the code in the following link

http://paste.mootools.net/f7e54d48f

I didn't tested it with diffrent browsers other then (ie7 and firefox
3)



On Mar 16, 2:25 pm, Leeb <[email protected]> wrote:
> I have been testing this bug both on IE7 and Firefox 3
>
>  short description:
>  when creating an array and intilizing elements with not consecutive
> index
> the $each() function will not iterate over the array as expected, for
> me its returned
> some undefiend.
> while in firefox its work as expected.
>
> currently to solve the problem I use the Hash.each to get it work on
> both browsers
>
> more to note that firefox, work both with Hash.each and Array.each
> with the same result
>
> --------------------------------------
> here is a small unit test i created
>
> ------
> function TEST_0001(){
> /*
> Test Description
>         Create an Array
>         Assign element with "random" indexs
>         Iterate over the Elements using $each
> */
> myTest = Array();
>         myTest[1] = 'I ';
>         myTest[4] = 'In ';
>         myTest[7] = 'Order ';
>         myTest[5] = 'The Right ';
>         myTest[2] = 'Am ';
>
> result = "";
> $each(myTest,function(t,i){
>         //alert(i + ' : ' + t);
>         result += t ;
>
> }.bind(result));
>
> if (result == 'I Am In The Right Order '){
>         return true;
>         }  else {
>         return false;
>         }
>
> }
>
> function TEST_0002(){
> /*
> Test Description
>         Create an Array
>         Assign element with "random" indexs
>         Iterate over the Elements using Array.each
>
> */
> myTest = Array();
>         myTest[1] = 'I ';
>         myTest[4] = 'In ';
>         myTest[7] = 'Order ';
>         myTest[5] = 'The Right ';
>         myTest[2] = 'Am ';
>
> result = "";
> Array.each(myTest,function(t,i){
>         //alert(i + ' : ' + t);
>         result += t ;
>
> }.bind(result));
>
> if (result == 'I Am In The Right Order '){
>         return true;
>         }  else {
>         return false;
>         }
>
> }
>
> function TEST_0003(){
> /*
> Test Description
>         Create an Array
>         Assign element with "random" indexs
>         Iterate over the Elements using Hash.each
>
> both firefox and IE will pass this test
> the only diffrent is that firefox will sort the element by index order
> while IE will iterate over the element in the same order they
> "assigned"
>
> */
> myTest = Array();
>         myTest[1] = 'I ';
>         myTest[4] = 'In ';
>         myTest[7] = 'Order ';
>         myTest[5] = 'The Right ';
>         myTest[2] = 'Am ';
>
> result = "";
> Hash.each(myTest,function(t,i){
>         //alert(i + ' : ' + t);
>         result += t ;}.bind(result));
>
> alert(result);
> if (result == 'I Am In The Right Order ' || result == 'I In Order The
> Right Am '){    //the order is less importent
>         return true;
>         }  else {
>         return false;
>         }
>
> }
>
>         alert(TEST_0001.run()?'passed':'failed');       //$each
>         alert(TEST_0002.run()?'passed':'failed');       //Array.each
>         alert(TEST_0003.run()?'passed':'failed');       //Hash.each

Reply via email to