I founded an error in my code. Instead of
array.splice(i--, 1); goes array.splice(i, 1); On Feb 17, 8:59 am, Robert Katić <robert.ka...@gmail.com> wrote: > To ensure order and uniqueness with XML and non current documents too, > we have to ensure that the NodeList "allSort" is the correct one. > Maybe something like this: > > function sortNodes( array ) { > if ( array.length === 0 ) > return; > > if ( allSort && allSort._document !== array[0].ownerDocument ) { > var doc = array[0].ownerDocument; > allSort = doc.getElementsByTagName("*"); > allSort._document = doc; > } > > hasDuplicate = false; > array.sort(sortOrder); > > if ( hasDuplicate ) { > var i = array.length; > while ( i-- ) { > if ( array[i] === array[i-1] ) { > array.splice(i--, 1); > } > } > } > > } > > You will notice that this sorting function removes duplicates too. The > reason way I putted all inside, is the possibility to easily expose > this functionality to the API. > > So in function Sizzle (line 115) it can be used like this: > > if ( sortOrder && arguments.callee !== arguments.callee.caller ) { > sortNodes( results ); > > } > > Of course, in that case you will add this on line 689: > > allSort._document = document; > > or simply replace line 688 with: > > allSort = true; > > Or is there something that I haven't catch? > > On Feb 14, 7:11 pm, John Resig <jere...@gmail.com> wrote: > > > > Nice job John, I like your solution very much. > > > Thanks! > > > > But if I am right, the querySelectorAll will always fall with no > > > standard filters, so we have to ensure order and uniqueness on all > > > browsers (?). > > > Ah - so you mean the case where someone does: "div:first, p:first" > > > Hmm - good point. I just landed a solution for this that seems to work > > well:http://github.com/jeresig/sizzle/commit/c2f4a8a68f59409e86d6b0c01edea... > > > --John > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---