From 9a5033d41350f83d3b4814648934618ab4648e27 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 9 Apr 2020 20:56:43 +0300 Subject: [PATCH] Pass multiple classes to `classList.add` / `classList.remove` (#30537) This is supported by our currently supported browsers. --- js/src/carousel.js | 7 ++----- js/src/collapse.js | 6 ++---- js/src/popover.js | 3 +-- js/src/tooltip.js | 3 +-- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/js/src/carousel.js b/js/src/carousel.js index 3020974d38..a5451538cd 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -478,13 +478,10 @@ class Carousel { EventHandler .one(activeElement, TRANSITION_END, () => { - nextElement.classList.remove(directionalClassName) - nextElement.classList.remove(orderClassName) + nextElement.classList.remove(directionalClassName, orderClassName) nextElement.classList.add(CLASS_NAME_ACTIVE) - activeElement.classList.remove(CLASS_NAME_ACTIVE) - activeElement.classList.remove(orderClassName) - activeElement.classList.remove(directionalClassName) + activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName) this._isSliding = false diff --git a/js/src/collapse.js b/js/src/collapse.js index fde3e0a9ed..4529a85ec3 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -192,8 +192,7 @@ class Collapse { const complete = () => { this._element.classList.remove(CLASS_NAME_COLLAPSING) - this._element.classList.add(CLASS_NAME_COLLAPSE) - this._element.classList.add(CLASS_NAME_SHOW) + this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW) this._element.style[dimension] = '' @@ -230,8 +229,7 @@ class Collapse { reflow(this._element) this._element.classList.add(CLASS_NAME_COLLAPSING) - this._element.classList.remove(CLASS_NAME_COLLAPSE) - this._element.classList.remove(CLASS_NAME_SHOW) + this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW) const triggerArrayLength = this._triggerArray.length if (triggerArrayLength > 0) { diff --git a/js/src/popover.js b/js/src/popover.js index 2d423f0dd5..4aac7e8ab2 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -113,8 +113,7 @@ class Popover extends Tooltip { this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content) - tip.classList.remove(CLASS_NAME_FADE) - tip.classList.remove(CLASS_NAME_SHOW) + tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW) } _addAttachmentClass(attachment) { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 9a1dff3d6e..3f40b3da12 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -400,8 +400,7 @@ class Tooltip { setContent() { const tip = this.getTipElement() this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle()) - tip.classList.remove(CLASS_NAME_FADE) - tip.classList.remove(CLASS_NAME_SHOW) + tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW) } setElementContent(element, content) {