MCPcopy Create free account
hub / github.com/TruthHun/BookStack / addClass

Function addClass

static/vuejs/vue.runtime.common.js:5696–5715  ·  view source on GitHub ↗

* Add class with compatibility for SVG since classList is not supported on * SVG elements in IE

(el, cls)

Source from the content-addressed store, hash-verified

5694 * SVG elements in IE
5695 */
5696function 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

Callers 2

addTransitionClassFunction · 0.70

Calls 2

getAttributeMethod · 0.80
setAttributeMethod · 0.45

Tested by

no test coverage detected