mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
Change selector-engine.js parents
method to utilize better js native methods (#35684)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
parent
89f88762c5
commit
882185bbde
@ -11,8 +11,6 @@ import { isDisabled, isVisible } from '../util/index'
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const NODE_TEXT = 3
|
||||
|
||||
const SelectorEngine = {
|
||||
find(selector, element = document.documentElement) {
|
||||
return [].concat(...Element.prototype.querySelectorAll.call(element, selector))
|
||||
@ -28,14 +26,11 @@ const SelectorEngine = {
|
||||
|
||||
parents(element, selector) {
|
||||
const parents = []
|
||||
let ancestor = element.parentNode
|
||||
let ancestor = element.parentNode.closest(selector)
|
||||
|
||||
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
|
||||
if (ancestor.matches(selector)) {
|
||||
parents.push(ancestor)
|
||||
}
|
||||
|
||||
ancestor = ancestor.parentNode
|
||||
while (ancestor) {
|
||||
parents.push(ancestor)
|
||||
ancestor = ancestor.parentNode.closest(selector)
|
||||
}
|
||||
|
||||
return parents
|
||||
|
Loading…
Reference in New Issue
Block a user