diff options
Diffstat (limited to 'js/src/dom/polyfill.js')
-rw-r--r-- | js/src/dom/polyfill.js | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/js/src/dom/polyfill.js b/js/src/dom/polyfill.js deleted file mode 100644 index c5318a1300..0000000000 --- a/js/src/dom/polyfill.js +++ /dev/null @@ -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 -} |