mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-29 21:52:22 +01:00
use our selector engine instead of native api
This commit is contained in:
parent
5877306104
commit
fee11fd7ae
@ -74,11 +74,11 @@ class Collapse {
|
|||||||
`[data-toggle="collapse"][data-target="#${element.id}"]`
|
`[data-toggle="collapse"][data-target="#${element.id}"]`
|
||||||
))
|
))
|
||||||
|
|
||||||
const toggleList = Util.makeArray(document.querySelectorAll(Selector.DATA_TOGGLE))
|
const toggleList = Util.makeArray(SelectorEngine.find(Selector.DATA_TOGGLE))
|
||||||
for (let i = 0, len = toggleList.length; i < len; i++) {
|
for (let i = 0, len = toggleList.length; i < len; i++) {
|
||||||
const elem = toggleList[i]
|
const elem = toggleList[i]
|
||||||
const selector = Util.getSelectorFromElement(elem)
|
const selector = Util.getSelectorFromElement(elem)
|
||||||
const filterElement = Util.makeArray(document.querySelectorAll(selector))
|
const filterElement = Util.makeArray(SelectorEngine.find(selector))
|
||||||
.filter((foundElem) => foundElem === element)
|
.filter((foundElem) => foundElem === element)
|
||||||
|
|
||||||
if (selector !== null && filterElement.length) {
|
if (selector !== null && filterElement.length) {
|
||||||
@ -130,7 +130,7 @@ class Collapse {
|
|||||||
let activesData
|
let activesData
|
||||||
|
|
||||||
if (this._parent) {
|
if (this._parent) {
|
||||||
actives = Util.makeArray(this._parent.querySelectorAll(Selector.ACTIVES))
|
actives = Util.makeArray(SelectorEngine.find(Selector.ACTIVES, this._parent))
|
||||||
.filter((elem) => {
|
.filter((elem) => {
|
||||||
if (typeof this._config.parent === 'string') {
|
if (typeof this._config.parent === 'string') {
|
||||||
return elem.getAttribute('data-parent') === this._config.parent
|
return elem.getAttribute('data-parent') === this._config.parent
|
||||||
@ -343,7 +343,7 @@ class Collapse {
|
|||||||
|
|
||||||
static _getTargetFromElement(element) {
|
static _getTargetFromElement(element) {
|
||||||
const selector = Util.getSelectorFromElement(element)
|
const selector = Util.getSelectorFromElement(element)
|
||||||
return selector ? document.querySelector(selector) : null
|
return selector ? SelectorEngine.findOne(selector) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
static _collapseInterface(element, config) {
|
static _collapseInterface(element, config) {
|
||||||
|
@ -152,7 +152,7 @@ class Dropdown {
|
|||||||
* Popper - https://popper.js.org
|
* Popper - https://popper.js.org
|
||||||
*/
|
*/
|
||||||
if (typeof Popper === 'undefined') {
|
if (typeof Popper === 'undefined') {
|
||||||
throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)')
|
throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)')
|
||||||
}
|
}
|
||||||
|
|
||||||
let referenceElement = this._element
|
let referenceElement = this._element
|
||||||
@ -286,7 +286,7 @@ class Dropdown {
|
|||||||
const parent = Dropdown._getParentFromElement(this._element)
|
const parent = Dropdown._getParentFromElement(this._element)
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
this._menu = parent.querySelector(Selector.MENU)
|
this._menu = SelectorEngine.findOne(Selector.MENU, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._menu
|
return this._menu
|
||||||
@ -442,7 +442,7 @@ class Dropdown {
|
|||||||
const selector = Util.getSelectorFromElement(element)
|
const selector = Util.getSelectorFromElement(element)
|
||||||
|
|
||||||
if (selector) {
|
if (selector) {
|
||||||
parent = document.querySelector(selector)
|
parent = SelectorEngine.findOne(selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent || element.parentNode
|
return parent || element.parentNode
|
||||||
@ -482,7 +482,7 @@ class Dropdown {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = Util.makeArray(parent.querySelectorAll(Selector.VISIBLE_ITEMS))
|
const items = Util.makeArray(SelectorEngine.find(Selector.VISIBLE_ITEMS, parent))
|
||||||
|
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
return
|
return
|
||||||
|
@ -246,7 +246,7 @@ class Modal {
|
|||||||
this._element.setAttribute('aria-modal', true)
|
this._element.setAttribute('aria-modal', true)
|
||||||
|
|
||||||
if (this._dialog.classList.contains(ClassName.SCROLLABLE)) {
|
if (this._dialog.classList.contains(ClassName.SCROLLABLE)) {
|
||||||
this._dialog.querySelector(Selector.MODAL_BODY).scrollTop = 0
|
SelectorEngine.findOne(Selector.MODAL_BODY, this._dialog).scrollTop = 0
|
||||||
} else {
|
} else {
|
||||||
this._element.scrollTop = 0
|
this._element.scrollTop = 0
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class ScrollSpy {
|
|||||||
|
|
||||||
this._scrollHeight = this._getScrollHeight()
|
this._scrollHeight = this._getScrollHeight()
|
||||||
|
|
||||||
const targets = Util.makeArray(document.querySelectorAll(this._selector))
|
const targets = Util.makeArray(SelectorEngine.find(this._selector))
|
||||||
|
|
||||||
targets
|
targets
|
||||||
.map((element) => {
|
.map((element) => {
|
||||||
@ -126,7 +126,7 @@ class ScrollSpy {
|
|||||||
const targetSelector = Util.getSelectorFromElement(element)
|
const targetSelector = Util.getSelectorFromElement(element)
|
||||||
|
|
||||||
if (targetSelector) {
|
if (targetSelector) {
|
||||||
target = document.querySelector(targetSelector)
|
target = SelectorEngine.findOne(targetSelector)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
@ -284,7 +284,7 @@ class ScrollSpy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_clear() {
|
_clear() {
|
||||||
Util.makeArray(document.querySelectorAll(this._selector))
|
Util.makeArray(SelectorEngine.find(this._selector))
|
||||||
.filter((node) => node.classList.contains(ClassName.ACTIVE))
|
.filter((node) => node.classList.contains(ClassName.ACTIVE))
|
||||||
.forEach((node) => node.classList.remove(ClassName.ACTIVE))
|
.forEach((node) => node.classList.remove(ClassName.ACTIVE))
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selector) {
|
if (selector) {
|
||||||
target = document.querySelector(selector)
|
target = SelectorEngine.findOne(selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
this._activate(
|
this._activate(
|
||||||
@ -193,7 +193,7 @@ class Tab {
|
|||||||
const dropdownElement = SelectorEngine.closest(element, Selector.DROPDOWN)
|
const dropdownElement = SelectorEngine.closest(element, Selector.DROPDOWN)
|
||||||
|
|
||||||
if (dropdownElement) {
|
if (dropdownElement) {
|
||||||
Util.makeArray(dropdownElement.querySelectorAll(Selector.DROPDOWN_TOGGLE))
|
Util.makeArray(SelectorEngine.find(Selector.DROPDOWN_TOGGLE))
|
||||||
.forEach((dropdown) => dropdown.classList.add(ClassName.ACTIVE))
|
.forEach((dropdown) => dropdown.classList.add(ClassName.ACTIVE))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user