Sorry about the duplicate post. I posted first got an error, and for some reason could not recover my original contents, so I rewrote it and reposted. Surprise surprise now, they are both posted....
On Jul 7, 12:04 pm, joelarson <[EMAIL PROTECTED]> wrote: > Is this a bug or simply a change in functionality I should be prepared > to cope with? > > This code > ------------------ > <script src="http://jqueryjs.googlecode.com/files/jquery-1.2.5.js"></ > script> > <span>1</span><span>2</span><span>3</span> > <script language=JavaScript><!--// > $(function() { > var arr=$("span").get(); > var txt=[]; > for(ai in arr) { txt.push(arr[ai].innerHTML); } > alert("via get(): "+txt.join(",")); > $("span").each(function(i,o) { alert("via each #"+i > +".html="+o.innerHTML); }); > }); > //--></script> > ------------------ > > Will alert you "via get(): 3,2,1", however the each loop will report > the innerhtmls of the elements in order 1,2,3. Earlier versions of > jquery (1.2.4 and lower) will report "via get(): 1,2,3". > > Although the order of elements is not specified in the documentation, > I think that expecting them to be returned in document order is the > only rational behavior. Is this an unintentional change? > > It seems to boil down to a change in how the array is constructed in > makeArray. In 1.2.4 it was done in order via: > > ------------------ > for ( var i = 0, length = array.length; i < length; i++ ) > ret.push( array[ i ] ); > ------------------ > > whereas in 1.2.5 and 1.2.6 it is done by more consise, but reversing: > > ------------------ > while( i ) > ret[--i] = array[i]; > ------------------ > > A simple way to fix this would be to insert "ret.reverse()" just > before ret is returned. > > If there is somewhere I could have noted this as an existing bug or an > intentional change, I am sorry, I have looked all over. Let me know > where I should have looked. > > Thanks!