]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
docs(cheatsheet): fix JS errors in `setActiveItem()` (#34011)
authorGaël Poupard <ffoodd@users.noreply.github.com>
Tue, 18 May 2021 05:31:15 +0000 (07:31 +0200)
committerGitHub <noreply@github.com>
Tue, 18 May 2021 05:31:15 +0000 (08:31 +0300)
site/content/docs/5.0/examples/cheatsheet/cheatsheet.js

index 541cf9350a1ec9aa0f2417f82143b7930c71e84d..0a50258b92331ed010af861a38c0a7d76a351e25 100644 (file)
@@ -25,8 +25,8 @@
       toast.show()
     })
 
-  // Disable empty links
-  document.querySelectorAll('[href="#"]')
+  // Disable empty links and submit buttons
+  document.querySelectorAll('[href="#"], [type="submit"]')
     .forEach(function (link) {
       link.addEventListener('click', function (event) {
         event.preventDefault()
     }
 
     var link = document.querySelector('.bd-aside a[href="' + hash + '"]')
+
+    if (!link) {
+      return
+    }
+
     var active = document.querySelector('.bd-aside .active')
     var parent = link.parentNode.parentNode.previousElementSibling