From: rwldrn Date: Wed, 22 Jun 2011 12:50:44 +0000 (-0400) Subject: Filter hasClass by nodeType 1; Fixes #9630 X-Git-Tag: 1.6.3rc1~36^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F419%2Fhead;p=jquery.git Filter hasClass by nodeType 1; Fixes #9630 --- diff --git a/src/attributes.js b/src/attributes.js index 1e0e79f4b..c862f38c6 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -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; } } diff --git a/test/unit/attributes.js b/test/unit/attributes.js index bc3eb25f5..578fd71a9 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -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)" ); });