diff options
-rw-r--r-- | build/build-plugins.js | 7 | ||||
-rw-r--r-- | js/src/dom/polyfill.js | 65 | ||||
-rw-r--r-- | js/src/dom/selector-engine.js | 6 | ||||
-rw-r--r-- | js/tests/karma.conf.js | 10 | ||||
-rw-r--r-- | js/tests/visual/alert.html | 1 | ||||
-rw-r--r-- | js/tests/visual/button.html | 1 | ||||
-rw-r--r-- | js/tests/visual/carousel.html | 1 | ||||
-rw-r--r-- | js/tests/visual/collapse.html | 1 | ||||
-rw-r--r-- | js/tests/visual/dropdown.html | 1 | ||||
-rw-r--r-- | js/tests/visual/modal.html | 1 | ||||
-rw-r--r-- | js/tests/visual/popover.html | 1 | ||||
-rw-r--r-- | js/tests/visual/scrollspy.html | 1 | ||||
-rw-r--r-- | js/tests/visual/tab.html | 1 | ||||
-rw-r--r-- | js/tests/visual/toast.html | 1 | ||||
-rw-r--r-- | js/tests/visual/tooltip.html | 1 |
15 files changed, 3 insertions, 96 deletions
diff --git a/build/build-plugins.js b/build/build-plugins.js index c5c357645b..6d9cdb3324 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 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) { diff --git a/js/tests/karma.conf.js b/js/tests/karma.conf.js index 688868b189..3cb7f808f5 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 7817dba68f..f94d86d95e 100644 --- a/js/tests/visual/alert.html +++ b/js/tests/visual/alert.html @@ -51,7 +51,6 @@ </div> </div> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/data.js"></script> diff --git a/js/tests/visual/button.html b/js/tests/visual/button.html index 6908361a64..14cc208704 100644 --- a/js/tests/visual/button.html +++ b/js/tests/visual/button.html @@ -44,7 +44,6 @@ </div> </div> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/data.js"></script> diff --git a/js/tests/visual/carousel.html b/js/tests/visual/carousel.html index 5588d06dad..44fdff8184 100644 --- a/js/tests/visual/carousel.html +++ b/js/tests/visual/carousel.html @@ -45,7 +45,6 @@ </div> </div> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/manipulator.js"></script> diff --git a/js/tests/visual/collapse.html b/js/tests/visual/collapse.html index e33148ac80..f36f73f7e6 100644 --- a/js/tests/visual/collapse.html +++ b/js/tests/visual/collapse.html @@ -71,7 +71,6 @@ </div> </div> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/manipulator.js"></script> diff --git a/js/tests/visual/dropdown.html b/js/tests/visual/dropdown.html index fffde819a4..0816683be4 100644 --- a/js/tests/visual/dropdown.html +++ b/js/tests/visual/dropdown.html @@ -210,7 +210,6 @@ </div> <script src="../../../node_modules/popper.js/dist/umd/popper.min.js"></script> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/data.js"></script> diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html index eabc63318d..13e93d154f 100644 --- a/js/tests/visual/modal.html +++ b/js/tests/visual/modal.html @@ -206,7 +206,6 @@ </div> <script src="../../../node_modules/popper.js/dist/umd/popper.min.js"></script> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/data.js"></script> diff --git a/js/tests/visual/popover.html b/js/tests/visual/popover.html index c28c7ec2ed..b6ca7dc248 100644 --- a/js/tests/visual/popover.html +++ b/js/tests/visual/popover.html @@ -32,7 +32,6 @@ </div> <script src="../../../node_modules/popper.js/dist/umd/popper.min.js"></script> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/manipulator.js"></script> diff --git a/js/tests/visual/scrollspy.html b/js/tests/visual/scrollspy.html index 2ed553d5d2..6da8a51bf1 100644 --- a/js/tests/visual/scrollspy.html +++ b/js/tests/visual/scrollspy.html @@ -86,7 +86,6 @@ <p>Ad leggings keytar, brunch id art party dolor labore.</p> </div> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/data.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> diff --git a/js/tests/visual/tab.html b/js/tests/visual/tab.html index 509401d0dc..a221f971e6 100644 --- a/js/tests/visual/tab.html +++ b/js/tests/visual/tab.html @@ -222,7 +222,6 @@ </div> <script src="../../../node_modules/popper.js/dist/umd/popper.min.js"></script> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/data.js"></script> diff --git a/js/tests/visual/toast.html b/js/tests/visual/toast.html index 13d32fab45..046c4345c0 100644 --- a/js/tests/visual/toast.html +++ b/js/tests/visual/toast.html @@ -52,7 +52,6 @@ </div> </div> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/manipulator.js"></script> <script src="../../dist/dom/data.js"></script> diff --git a/js/tests/visual/tooltip.html b/js/tests/visual/tooltip.html index c06ac739b0..14f704b934 100644 --- a/js/tests/visual/tooltip.html +++ b/js/tests/visual/tooltip.html @@ -70,7 +70,6 @@ </div> <script src="../../../node_modules/popper.js/dist/umd/popper.min.js"></script> - <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/selector-engine.js"></script> <script src="../../dist/dom/event-handler.js"></script> <script src="../../dist/dom/manipulator.js"></script> |