* Add class with compatibility for SVG since classList is not supported on * SVG elements in IE
(el, cls)
| 6142 | * SVG elements in IE |
| 6143 | */ |
| 6144 | function addClass (el, cls) { |
| 6145 | /* istanbul ignore if */ |
| 6146 | if (!cls || !(cls = cls.trim())) { |
| 6147 | return |
| 6148 | } |
| 6149 | |
| 6150 | /* istanbul ignore else */ |
| 6151 | if (el.classList) { |
| 6152 | if (cls.indexOf(' ') > -1) { |
| 6153 | cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); }); |
| 6154 | } else { |
| 6155 | el.classList.add(cls); |
| 6156 | } |
| 6157 | } else { |
| 6158 | var cur = " " + (el.getAttribute('class') || '') + " "; |
| 6159 | if (cur.indexOf(' ' + cls + ' ') < 0) { |
| 6160 | el.setAttribute('class', (cur + cls).trim()); |
| 6161 | } |
| 6162 | } |
| 6163 | } |
| 6164 | |
| 6165 | /** |
| 6166 | * Remove class with compatibility for SVG since classList is not supported on |
no test coverage detected