Skip to content
Permalink
Browse files
Filter hasClass by nodeType 1; Fixes #9630
  • Loading branch information
rwaldron committed Jun 22, 2011
1 parent 27e5052 commit bb1702518e43e88c31922af8b0f3bd4aa29017d2
Showing 2 changed files with 2 additions and 2 deletions.
@@ -146,7 +146,7 @@ jQuery.fn.extend({
hasClass: function( selector ) {
var className = " " + selector + " ";
for ( var i = 0, l = this.length; i < l; i++ ) {
if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
return true;
}
}
@@ -1063,5 +1063,5 @@ test("contents().hasClass() returns correct values", function() {
$contents = $div.contents();

ok( $contents.hasClass("foo"), "Found 'foo' in $contents" );
ok( $contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" );
ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" );
});

0 comments on commit bb17025

Please sign in to comment.