Skip to main content

Bug Tracker

Side navigation

Ticket #5380: selector.js.patch


File selector.js.patch, 0.7 KB (added by antonkovalyov, October 15, 2009 12:13AM UTC)
Index: src/selector.js
===================================================================
--- src/selector.js	(revision 6617)
+++ src/selector.js	(working copy)
@@ -133,7 +133,11 @@
 
 Sizzle.uniqueSort = function(results){
 	if ( sortOrder ) {
-		hasDuplicate = false;
+		/* Here we check if the JavaScript engine is using some sort of
+		 * optimization where it does not always call our comparision
+		 * function. If that is the case, discard the hasDuplicate value. */
+		hasDuplicate = true;
+		['', ''].sort(function(a,b) { hasDuplicate = false; return 0; });
 		results.sort(sortOrder);
 
 		if ( hasDuplicate ) {
@@ -144,7 +148,6 @@
 			}
 		}
 	}
-
 	return results;
 };

Download in other formats:

Original Format