1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-18 11:21:23 +02:00

polyfill.js minor tweaks (#32011)

* rename function to `supportsScopeQuery`
* use a ternary in `findOne` function return value
This commit is contained in:
XhmikosR
2020-11-01 07:38:55 +02:00
committed by GitHub
parent d1dcc1e5e6
commit e6f8428b28

View File

@@ -27,7 +27,7 @@ const defaultPreventedPreservedOnDispatch = (() => {
})() })()
const scopeSelectorRegex = /:scope\b/ const scopeSelectorRegex = /:scope\b/
const supportScopeQuery = (() => { const supportsScopeQuery = (() => {
const element = document.createElement('div') const element = document.createElement('div')
try { try {
@@ -39,7 +39,7 @@ const supportScopeQuery = (() => {
return true return true
})() })()
if (!supportScopeQuery) { if (!supportsScopeQuery) {
find = function (selector) { find = function (selector) {
if (!scopeSelectorRegex.test(selector)) { if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector) return this.querySelectorAll(selector)
@@ -71,11 +71,7 @@ if (!supportScopeQuery) {
const matches = find.call(this, selector) const matches = find.call(this, selector)
if (typeof matches[0] !== 'undefined') { return matches[0] ? matches[0] : null
return matches[0]
}
return null
} }
} }