diff options
| author | Johann-S <[email protected]> | 2018-06-01 14:44:21 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2018-06-03 11:40:08 +0200 |
| commit | a79b8aa16ab5fa5c71a91425d8464f0bdcd3fe37 (patch) | |
| tree | 201e8438a9df0d1e951bee801808a396fd3fc098 /js/src/carousel.js | |
| parent | ffd31f9b8c8b3a34df888fd66218ee74f1fcaf28 (diff) | |
| download | bootstrap-a79b8aa16ab5fa5c71a91425d8464f0bdcd3fe37.tar.xz bootstrap-a79b8aa16ab5fa5c71a91425d8464f0bdcd3fe37.zip | |
refactor(plugins): query elements without jquery
Diffstat (limited to 'js/src/carousel.js')
| -rw-r--r-- | js/src/carousel.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index 7616e53bb..59115de17 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -99,7 +99,7 @@ const Carousel = (($) => { this._config = this._getConfig(config) this._element = $(element)[0] - this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0] + this._indicatorsElement = this._element.querySelector(Selector.INDICATORS) this._addEventListeners() } @@ -142,7 +142,7 @@ const Carousel = (($) => { this._isPaused = true } - if ($(this._element).find(Selector.NEXT_PREV)[0]) { + if (this._element.querySelector(Selector.NEXT_PREV)) { Util.triggerTransitionEnd(this._element) this.cycle(true) } @@ -170,7 +170,7 @@ const Carousel = (($) => { } to(index) { - this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0] + this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM) const activeIndex = this._getItemIndex(this._activeElement) @@ -269,7 +269,9 @@ const Carousel = (($) => { } _getItemIndex(element) { - this._items = $.makeArray($(element).parent().find(Selector.ITEM)) + this._items = element && element.parentNode + ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) + : [] return this._items.indexOf(element) } @@ -294,7 +296,7 @@ const Carousel = (($) => { _triggerSlideEvent(relatedTarget, eventDirectionName) { const targetIndex = this._getItemIndex(relatedTarget) - const fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]) + const fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM)) const slideEvent = $.Event(Event.SLIDE, { relatedTarget, direction: eventDirectionName, @@ -309,8 +311,8 @@ const Carousel = (($) => { _setActiveIndicatorElement(element) { if (this._indicatorsElement) { - $(this._indicatorsElement) - .find(Selector.ACTIVE) + const indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE)) + $(indicators) .removeClass(ClassName.ACTIVE) const nextIndicator = this._indicatorsElement.children[ @@ -324,7 +326,7 @@ const Carousel = (($) => { } _slide(direction, element) { - const activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0] + const activeElement = this._element.querySelector(Selector.ACTIVE_ITEM) const activeElementIndex = this._getItemIndex(activeElement) const nextElement = element || activeElement && this._getItemByDirection(direction, activeElement) |
