Skip to main content

Bug Tracker

Side navigation

Ticket #4817: jquery-hasClass.diff
File jquery-hasClass.diff, 0.5 KB (added by sixtease, June 25, 2009 09:31AM UTC)

patch

Index: jquery/src/attributes.js
===================================================================
--- jquery/src/attributes.js	(revision 6414)
+++ jquery/src/attributes.js	(working copy)
@@ -36,7 +36,12 @@
 	},
 
 	hasClass: function( selector ) {
-		return !!selector && this.is( "." + selector );
+		return !!selector && this.is(
+			"." +							// prepend dot to look for class
+			jQuery.trim(selector)			// trim blanks
+			.replace(/([:.#])/g, '\\$1')	// escape metachars
+			.replace(/\s+/g, '.')			// join space-separated classes with dots
+		);
 	},

Download in other formats:

Original Format