Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2616 from arian/fix-ie8-hasClass-contains
Fixing hasClass without classList, which cannot use .contains anymore.
  • Loading branch information
ibolmo committed Jun 16, 2014
2 parents b553142 + 25bffac commit 6808764
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Element/Element.js
Expand Up @@ -732,7 +732,7 @@ Element.implement({
hasClass: hasClassList ? function(className){
return this.classList.contains(className);
} : function(className){
return this.className.clean().contains(className, ' ');
return classes(this.className).contains(className);
},

addClass: hasClassList ? function(className){
Expand Down
10 changes: 8 additions & 2 deletions Specs/Element/Element.js
Expand Up @@ -1072,10 +1072,16 @@ describe('Element.clone', function(){
describe('Element className methods', function(){

it('should return true if the Element has the given class', function(){
var div = new Element('div', {'class': 'header bold'});
var div = new Element('div', {'class': 'header bold\tunderline'});
expect(div.hasClass('header')).toBeTruthy();
expect(div.hasClass('bold')).toBeTruthy();
expect(div.hasClass('random')).toBeFalsy();
expect(div.hasClass('underline')).toBeTruthy();
});

it('should return false if the element does not have the given class', function(){
var div = new Element('div', {'class': 'header bold'});
expect(div.hasClass('italics')).toBeFalsy();
expect(div.hasClass('head')).toBeFalsy();
});

it('should add the class to the Element', function(){
Expand Down

0 comments on commit 6808764

Please sign in to comment.