* Add or remove a class/classes on an element * * @param {Element} el * @param {String} key The class name. This may or may not * contain a space character, in such a * case we'll deal with multiple class * names at once.
(el, key, fn)
| 5614 | */ |
| 5615 | |
| 5616 | function apply(el, key, fn) { |
| 5617 | key = key.trim(); |
| 5618 | if (key.indexOf(' ') === -1) { |
| 5619 | fn(el, key); |
| 5620 | return; |
| 5621 | } |
| 5622 | // The key contains one or more space characters. |
| 5623 | // Since a class name doesn't accept such characters, we |
| 5624 | // treat it as multiple classes. |
| 5625 | var keys = key.split(/\s+/); |
| 5626 | for (var i = 0, l = keys.length; i < l; i++) { |
| 5627 | fn(el, keys[i]); |
| 5628 | } |
| 5629 | } |
| 5630 | |
| 5631 | var component = { |
| 5632 |