Commit bb170251 authored by rwldrn's avatar rwldrn

Filter hasClass by nodeType 1; Fixes #9630

parent 27e5052a
...@@ -146,7 +146,7 @@ jQuery.fn.extend({ ...@@ -146,7 +146,7 @@ jQuery.fn.extend({
hasClass: function( selector ) { hasClass: function( selector ) {
var className = " " + selector + " "; var className = " " + selector + " ";
for ( var i = 0, l = this.length; i < l; i++ ) { 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; return true;
} }
} }
......
...@@ -1063,5 +1063,5 @@ test("contents().hasClass() returns correct values", function() { ...@@ -1063,5 +1063,5 @@ test("contents().hasClass() returns correct values", function() {
$contents = $div.contents(); $contents = $div.contents();
ok( $contents.hasClass("foo"), "Found 'foo' in $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)" );
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment