From: Gaƫl Poupard Date: Tue, 18 May 2021 05:31:15 +0000 (+0200) Subject: docs(cheatsheet): fix JS errors in `setActiveItem()` (#34011) X-Git-Tag: v5.0.2~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83bcc3c00f0d1fb166324f9f3ac8f4a9f3eee323;p=thirdparty%2Fbootstrap.git docs(cheatsheet): fix JS errors in `setActiveItem()` (#34011) --- diff --git a/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js b/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js index 541cf9350a..0a50258b92 100644 --- a/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js +++ b/site/content/docs/5.0/examples/cheatsheet/cheatsheet.js @@ -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() @@ -41,6 +41,11 @@ } 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