Skip to content

Commit

Permalink
hasClass() on an empty set should return false
Browse files Browse the repository at this point in the history
  • Loading branch information
bryfox committed Aug 24, 2010
1 parent c4ef1de commit 64bc66a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions spec/tests/core-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ CoreTests.prototype.run = function () {
test( 'should return false when element does not have the specified class', function(){
equals(x.hasClass('zug'), false, 'Element with id "has-class-element" should not have the class "zug"');
});

test('should return false when the selector matches zero elements', function () {
var y = x$('#this-should-never-exist-in-the-dom');
equals(y.length, 0);
equals(y.hasClass('bar'), false);
});

// --
/// dom specs
// --
Expand Down
2 changes: 1 addition & 1 deletion src/IE/core/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ xui.extend({
hasClass: function(className, callback) {
return (callback === undefined && this.length == 1) ?
hasClass(this[0], className) :
this.each(function(el) {
this.length && this.each(function(el) {
if (hasClass(el, className)) {
callback(el);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ xui.extend({
hasClass: function(className, callback) {
return (callback === undefined && this.length == 1) ?
hasClass(this[0], className) :
this.each(function(el) {
this.length && this.each(function(el) {
if (hasClass(el, className)) {
callback(el);
}
Expand Down

0 comments on commit 64bc66a

Please sign in to comment.