* Add class with compatibility for SVG since classList is not supported on * SVG elements in IE
(el, cls)
| 5694 | * SVG elements in IE |
| 5695 | */ |
| 5696 | function addClass (el, cls) { |
| 5697 | /* istanbul ignore if */ |
| 5698 | if (!cls || !(cls = cls.trim())) { |
| 5699 | return |
| 5700 | } |
| 5701 | |
| 5702 | /* istanbul ignore else */ |
| 5703 | if (el.classList) { |
| 5704 | if (cls.indexOf(' ') > -1) { |
| 5705 | cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); }); |
| 5706 | } else { |
| 5707 | el.classList.add(cls); |
| 5708 | } |
| 5709 | } else { |
| 5710 | var cur = " " + (el.getAttribute('class') || '') + " "; |
| 5711 | if (cur.indexOf(' ' + cls + ' ') < 0) { |
| 5712 | el.setAttribute('class', (cur + cls).trim()); |
| 5713 | } |
| 5714 | } |
| 5715 | } |
| 5716 | |
| 5717 | /** |
| 5718 | * Remove class with compatibility for SVG since classList is not supported on |
no test coverage detected