function toggleClass (el, type, val) {
  el && el.classList[val ? type : 'toggle'](val || type);
}
Toggle class

@example
toggleClass(el, 'active') => el.classList.toggle('active')
toggleClass(el, 'add', 'active') => el.classList.add('active')