Skip to content

Commit

Permalink
fix(classList): error on svg elements
Browse files Browse the repository at this point in the history
Fixes #1795
  • Loading branch information
adamdbradley committed Aug 28, 2014
1 parent 0b4cba8 commit 98629d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/angular/service/angularOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jqLite.prototype.addClass = function(cssClasses) {
el = this[x];
if(el.setAttribute) {

if(cssClasses.indexOf(' ') < 0) {
if(cssClasses.indexOf(' ') < 0 && el.classList.add) {

This comment has been minimized.

Copy link
@gkalpak

gkalpak Jan 2, 2015

@adamdbradley: If the problem is that certain elements on certain browsers do not have a classList, wouldn't it make more sense to also check for el.classList ? The current implementation will still throw an error if el.CLASSLIST is undefined.

el.classList.add(cssClasses);
} else {
existingClasses = (' ' + (el.getAttribute('class') || '') + ' ')
Expand All @@ -33,7 +33,7 @@ jqLite.prototype.removeClass = function(cssClasses) {
for(x=0; x<this.length; x++) {
el = this[x];
if(el.getAttribute) {
if(cssClasses.indexOf(' ') < 0) {
if(cssClasses.indexOf(' ') < 0 && el.classList.remove) {
el.classList.remove(cssClasses);
} else {
splitClasses = cssClasses.split(' ');
Expand Down

0 comments on commit 98629d4

Please sign in to comment.