mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Filter hasClass by nodeType 1; Fixes #9630
This commit is contained in:
parent
27e5052a7b
commit
bb1702518e
@ -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() {
|
|||||||
$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)" );
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user