mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-26 21:39:08 +02:00
refactor(plugins): query elements without jquery
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user