/**
 * Clear utility
 */
module.exports = classes;

var index = function(arr, obj) {
  if (arr.indexOf) {
     return arr.indexOf(obj);
  }


  for (var i = 0; i < arr.length; ++i) {
    if (arr[i] === obj) {
      return i;
    }
  }

  return -1;
};

var re = /\s+/;

var toString = Object.prototype.toString;

/**
 * Wrap `el` in a `ClassList`.
 *
 * @param {Element} el
 * @return {ClassList}
 * @api public
 */

function classes(el) {
  return new ClassList(el);
};

function ClassList(el) {
  if (!el || !el.nodeType) {
    throw new Error('A DOM element reference is required');
  }
  this.el = el;
  this.list = el.classList;
}

/**
 * Add class `name` if not already present.
 *
 * @param {String} name
 * @return {ClassList}
 * @api public
 */

ClassList.prototype.add = function(name) {

  // classList
  if (this.list) {
    this.list.add(name);
    return this;
  }

  // fallback
  var arr = this.array();
  var i = index(arr, name);
  if (!~i) arr.push(name);

  if (this.el.className.baseVal !== undefined) {
    this.el.className.baseVal = arr.join(' ');
  } else {
    this.el.className = arr.join(' ');
  }

  return this;
};

/**
 * Remove class `name` when present, or
 * pass a regular expression to remove
 * any which match.
 *
 * @param {String|RegExp} name
 * @return {ClassList}
 * @api public
 */

ClassList.prototype.remove = function(name) {
  if ('[object RegExp]' == toString.call(name)) {
    return this.removeMatching(name);
  }

  // classList
  if (this.list) {
    this.list.remove(name);
    return this;
  }

  // fallback
  var arr = this.array();
  var i = index(arr, name);
  if (~i) arr.splice(i, 1);
  this.el.className.baseVal = arr.join(' ');
  return this;
};

/**
 * Remove all classes matching `re`.
 *
 * @param {RegExp} re
 * @return {ClassList}
 * @api private
 */

ClassList.prototype.removeMatching = function(re) {
  var arr = this.array();
  for (var i = 0; i < arr.length; i++) {
    if (re.test(arr[i])) {
      this.remove(arr[i]);
    }
  }
  return this;
};

/**
 * Toggle class `name`, can force state via `force`.
 *
 * For browsers that support classList, but do not support `force` yet,
 * the mistake will be detected and corrected.
 *
 * @param {String} name
 * @param {Boolean} force
 * @return {ClassList}
 * @api public
 */

ClassList.prototype.toggle = function(name, force) {
  // classList
  if (this.list) {
    if ("undefined" !== typeof force) {
      if (force !== this.list.toggle(name, force)) {
        this.list.toggle(name); // toggle again to correct
      }
    } else {
      this.list.toggle(name);
    }
    return this;
  }

  // fallback
  if ("undefined" !== typeof force) {
    if (!force) {
      this.remove(name);
    } else {
      this.add(name);
    }
  } else {
    if (this.has(name)) {
      this.remove(name);
    } else {
      this.add(name);
    }
  }

  return this;
};

/**
 * Return an array of classes.
 *
 * @return {Array}
 * @api public
 */

ClassList.prototype.array = function() {
  var className = this.el.getAttribute('class') || '';
  var str = className.replace(/^\s+|\s+$/g, '');
  var arr = str.split(re);
  if ('' === arr[0]) arr.shift();
  return arr;
};

/**
 * Check if class `name` is present.
 *
 * @param {String} name
 * @return {ClassList}
 * @api public
 */

ClassList.prototype.has =
ClassList.prototype.contains = function(name) {
  return this.list
    ? this.list.contains(name)
    : !! ~index(this.array(), name);
};

@@ -496,19 +496,18 @@
 (el);%0D%0A%7D
-;
 %0D%0A
+
 %0D%0Afuncti
@@ -1013,16 +1013,23 @@
 if (!~i)
+ %7B%0D%0A   
  arr.pus
@@ -1037,16 +1037,21 @@
 (name);%0D
+%0A  %7D%0D
 %0A%0D%0A  if 
@@ -1487,16 +1487,17 @@
 Exp%5D' ==
+=
  toStrin
@@ -1729,16 +1729,23 @@
  if (~i)
+ %7B%0D%0A   
  arr.spl
@@ -1756,16 +1756,21 @@
 i, 1);%0D%0A
+  %7D%0D%0A
   this.e
@@ -3338,16 +3338,23 @@
  arr%5B0%5D)
+ %7B%0D%0A   
  arr.shi
@@ -3356,24 +3356,29 @@
 r.shift();%0D%0A
+  %7D%0D%0A
   return arr
@@ -3586,24 +3586,31 @@
 %7B%0D%0A  return 
+(%0D%0A    
 this.list%0D%0A 
@@ -3610,15 +3610,17 @@
 list
+ ?
 %0D%0A    
-?
+ 
  thi
@@ -3644,15 +3644,17 @@
 ame)
+ :
 %0D%0A    
-:
+ 
  !! 
@@ -3679,15 +3679,20 @@
 ), name)
+%0D%0A  )
 ;%0D%0A%7D;%0D%0A

correct linting errors