]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
polyfill.js minor tweaks (#32011)
authorXhmikosR <xhmikosr@gmail.com>
Sun, 1 Nov 2020 05:38:55 +0000 (07:38 +0200)
committerGitHub <noreply@github.com>
Sun, 1 Nov 2020 05:38:55 +0000 (07:38 +0200)
* rename function to `supportsScopeQuery`
* use a ternary in `findOne` function return value

js/src/dom/polyfill.js

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