Permalink
Browse files

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 6808764ca3d8e0faf41f6ceff6b1ba9e3f95cc03
Showing with 9 additions and 3 deletions.
  1. +1 −1 Source/Element/Element.js
  2. +8 −2 Specs/Element/Element.js
@@ -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){
View
@@ -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(){

0 comments on commit 6808764

Please sign in to comment.