dist/chirashi.common.js
function toggleClass(elements) {
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  if (_typeof(args[0]) === 'object') {
    forIn(args[0], _toggleClassesWithForce.bind(null, elements));
  } else {
    forEach(args, _toggleClassName.bind(null, elements));
  }
}
function toggleClass(elements) {
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  if (_typeof(args[0]) === 'object') {
    forIn(args[0], _toggleClassesWithForce.bind(null, elements));
  } else {
    forEach(args, _toggleClassName.bind(null, elements));
  }
}
function toggleClass ( elements ) { for ( var _len = arguments . length , args = Array ( _len > 1 ? _len - 1 : 0 ) , _key = 1 ; _key < _len ; _key ++ ) { args [ _key - 1 ] = arguments [ _key ] ; } if ( _typeof ( args [ 0 ] ) === 'object' ) { forIn ( args [ 0 ] , _toggleClassesWithForce . bind ( null , elements ) ) ; } else { forEach ( args , _toggleClassName . bind ( null , elements ) ) ; } }
Iterates over classes and toggle it on each element of elements.
@param {(string|Array|NodeList|HTMLCollection|Element)} elements - The iterable, selector or elements.
@param {(string|Array|Object)} classes - Array of classes or string of classes seperated with comma and/or spaces. Or object with keys being the string of classes seperated with comma and/or spaces and values function returning a booleanean.
@return {Array} iterable - The getElements' result for chaining.
@example //esnext
import { createElement, toggleClass, clone, setData, getData } from 'chirashi'
const maki = createElement('.wasabi.salmon.maki') //returns: <div class="maki salmon wasabi"></div>
const sushi = createElement('.salmon.sushi') //returns: <div class="sushi salmon"></div>
toggleClass([maki, sushi], 'wasabi') //returns: [<div class="maki salmon"></div>, <div class="sushi salmon wasabi"></div>]
const scdMaki = clone(maki)
setData(maki, { for: 'leonard' })
setData(scdMaki, { for: 'sheldon' })
toggleClass([maki, scdMaki], {
cheese: element => {
return getData(element, 'for') !== 'leonard'
}
}) //returns: [<div class="maki salmon cheese" data-for="sheldon"></div>, <div class="maki salmon" data-for="leonard"></div>]
@example //es5
var maki = Chirashi.createElement('.wasabi.salmon.maki') //returns: <div class="wasabi salmon maki"></div>
var sushi = Chirashi.createElement('.salmon.sushi') //returns: <div class="salmon sushi"></div>
Chirashi.toggleClass([maki, sushi], 'wasabi') //returns: [<div class="maki salmon"></div>, <div class="sushi salmon wasabi"></div>]
var scdMaki = Chirashi.clone(maki)
Chirashi.setData(maki, { for: 'leonard' })
Chirashi.setData(scdMaki, { for: 'sheldon' })
Chirashi.toggleClass([maki, scdMaki], {
cheese: function (element) {
return Chirashi.getData(element, 'for') !== 'leonard'
}
}) //returns: [<div class="maki salmon cheese" data-for="sheldon"></div>, <div class="maki salmon" data-for="leonard"></div>]
Iterates over classes and toggle it on each element of elements .