Skip to main content

Bug Tracker

Side navigation

Ticket #787: 787.patch
File 787.patch, 1.3 KB (added by Fil, January 11, 2007 10:21PM UTC)

test and fix for this bug ; .substring() is also used for speed

Index: src/selector/selector.js
===================================================================
--- src/selector/selector.js	(revision 1016)
+++ src/selector/selector.js	(working copy)
@@ -297,6 +297,10 @@
 	},
 
 	filter: function(t,r,not) {
+		// Support for array selectors
+		if ( typeof t == 'object' )
+			t = t.join(',');
+
 		// Look for common filter expressions
 		while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
 
@@ -312,13 +316,13 @@
 				var m = re.exec( t );
 
 				if ( m ) {
+					// Remove what we just matched
+					t = t.substring( m[0].length );
+
 					// Re-organize the first match
 					if ( jQuery.expr[ m[1] ]._resort )
 						m = jQuery.expr[ m[1] ]._resort( m );
 
-					// Remove what we just matched
-					t = t.replace( re, "" );
-
 					break;
 				}
 			}
Index: src/selector/selectorTest.js
===================================================================
--- src/selector/selectorTest.js	(revision 1016)
+++ src/selector/selectorTest.js	(working copy)
@@ -41,6 +41,12 @@
 	t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
 });
 
+test("expressions - array", function() {
+	expect(1);
+	t( "Array Support", ["a.blog", "div"], ["mark","simon","main","foo"] );
+});
+
+
 test("expressions - child and adjacent", function() {
 	expect(14);
 	t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );

Download in other formats:

Original Format