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