mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-25 14:30:46 +02:00
Remove the now unneeded polyfills.
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v5.0.0-alpha2): dom/polyfill.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import { getUID } from '../util/index'
|
||||
|
||||
let find = Element.prototype.querySelectorAll
|
||||
let findOne = Element.prototype.querySelector
|
||||
|
||||
const scopeSelectorRegex = /:scope\b/
|
||||
const supportsScopeQuery = (() => {
|
||||
const element = document.createElement('div')
|
||||
|
||||
try {
|
||||
element.querySelectorAll(':scope *')
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})()
|
||||
|
||||
if (!supportsScopeQuery) {
|
||||
find = function (selector) {
|
||||
if (!scopeSelectorRegex.test(selector)) {
|
||||
return this.querySelectorAll(selector)
|
||||
}
|
||||
|
||||
const hasId = Boolean(this.id)
|
||||
|
||||
if (!hasId) {
|
||||
this.id = getUID('scope')
|
||||
}
|
||||
|
||||
let nodeList = null
|
||||
try {
|
||||
selector = selector.replace(scopeSelectorRegex, `#${this.id}`)
|
||||
nodeList = this.querySelectorAll(selector)
|
||||
} finally {
|
||||
if (!hasId) {
|
||||
this.removeAttribute('id')
|
||||
}
|
||||
}
|
||||
|
||||
return nodeList
|
||||
}
|
||||
|
||||
findOne = function (selector) {
|
||||
if (!scopeSelectorRegex.test(selector)) {
|
||||
return this.querySelector(selector)
|
||||
}
|
||||
|
||||
const matches = find.call(this, selector)
|
||||
|
||||
return matches[0] ? matches[0] : null
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
find,
|
||||
findOne
|
||||
}
|
@@ -5,8 +5,6 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import { find as findFn, findOne } from './polyfill'
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
@@ -21,11 +19,11 @@ const SelectorEngine = {
|
||||
},
|
||||
|
||||
find(selector, element = document.documentElement) {
|
||||
return [].concat(...findFn.call(element, selector))
|
||||
return [].concat(...Element.prototype.querySelectorAll.call(element, selector))
|
||||
},
|
||||
|
||||
findOne(selector, element = document.documentElement) {
|
||||
return findOne.call(element, selector)
|
||||
return Element.prototype.querySelector.call(element, selector)
|
||||
},
|
||||
|
||||
children(element, selector) {
|
||||
|
Reference in New Issue
Block a user