diff --git a/build/build-plugins.js b/build/build-plugins.js index c5c357645bc7..6d9cdb332447 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -26,7 +26,6 @@ const bsPlugins = { Data: path.resolve(__dirname, '../js/src/dom/data.js'), EventHandler: path.resolve(__dirname, '../js/src/dom/event-handler.js'), Manipulator: path.resolve(__dirname, '../js/src/dom/manipulator.js'), - Polyfill: path.resolve(__dirname, '../js/src/dom/polyfill.js'), SelectorEngine: path.resolve(__dirname, '../js/src/dom/selector-engine.js'), Alert: path.resolve(__dirname, '../js/src/alert.js'), Button: path.resolve(__dirname, '../js/src/button.js'), @@ -66,10 +65,7 @@ const getConfigByPluginKey = pluginKey => { pluginKey === 'Sanitizer' ) { return { - external: [bsPlugins.Polyfill], - globals: { - [bsPlugins.Polyfill]: 'Polyfill' - } + external: [] } } @@ -138,7 +134,6 @@ const domObjects = [ 'Data', 'EventHandler', 'Manipulator', - 'Polyfill', 'SelectorEngine' ] diff --git a/js/src/dom/polyfill.js b/js/src/dom/polyfill.js deleted file mode 100644 index c5318a130063..000000000000 --- 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 481f5a100b84..f9c909060ba2 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) { diff --git a/js/tests/karma.conf.js b/js/tests/karma.conf.js index 688868b1892f..3cb7f808f553 100644 --- a/js/tests/karma.conf.js +++ b/js/tests/karma.conf.js @@ -137,16 +137,6 @@ if (browserStack) { branches: 89, functions: 90, lines: 90 - }, - each: { - overrides: { - 'js/src/dom/polyfill.js': { - statements: 30, - lines: 30, - branches: 8, - functions: 30 - } - } } } } diff --git a/js/tests/visual/alert.html b/js/tests/visual/alert.html index 7817dba68ffe..f94d86d95e59 100644 --- a/js/tests/visual/alert.html +++ b/js/tests/visual/alert.html @@ -51,7 +51,6 @@
Ad leggings keytar, brunch id art party dolor labore.
- diff --git a/js/tests/visual/tab.html b/js/tests/visual/tab.html index 509401d0dc6e..a221f971e655 100644 --- a/js/tests/visual/tab.html +++ b/js/tests/visual/tab.html @@ -222,7 +222,6 @@