diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-10-26 17:39:23 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2020-11-05 16:37:34 +0300 |
commit | 13572a6867f8f3275659bfb8874cc0ed6f63967b (patch) | |
tree | 3272c0f024b715ecbeb954d533b199fbf67ca098 /js/src/dom | |
parent | e8f1709adfd79bd8a9dd1e99b240edd39fd91d11 (diff) |
Remove the now unneeded polyfills.
Diffstat (limited to 'js/src/dom')
-rw-r--r-- | js/src/dom/polyfill.js | 65 | ||||
-rw-r--r-- | js/src/dom/selector-engine.js | 6 |
2 files changed, 2 insertions, 69 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 -} diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index 481f5a100b..f9c909060b 100644 --- a/js/src/dom/selector-engine.js +++ b/js/src/dom/selector-engine.js @@ -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) { |