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