]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
enforce element check on scrollspy target
authorJohann-S <johann.servoire@gmail.com>
Tue, 5 May 2020 19:42:58 +0000 (21:42 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 7 May 2020 06:31:49 +0000 (09:31 +0300)
js/src/scrollspy.js
js/tests/unit/scrollspy.js
site/docs/4.4/components/scrollspy.md

index 2c7c8a1dc8137d1aaa51f9e758c6079f8005c16a..bf546a25865674c5c1798385aa5331b2bbb057c0 100644 (file)
@@ -157,7 +157,7 @@ class ScrollSpy {
       ...typeof config === 'object' && config ? config : {}
     }
 
-    if (typeof config.target !== 'string') {
+    if (typeof config.target !== 'string' && Util.isElement(config.target)) {
       let id = $(config.target).attr('id')
       if (!id) {
         id = Util.getUID(NAME)
index c311c84237543137ca7b9489add2a9702cb3be7d..6f5c92caba5a1ad45f313a51fa5ad3bf63625e87 100644 (file)
@@ -127,7 +127,7 @@ $(function () {
       .show()
       .find('#scrollspy-example')
       .bootstrapScrollspy({
-        target: document.getElementById('#ss-target')
+        target: document.getElementById('ss-target')
       })
 
     $scrollspy.one('scroll', function () {
index 43443e7fbea683fb086feca92efd57491a21bf62..eb5b4ba6ff42ce80e4f0328e6a05d0f8eb58f8b9 100644 (file)
@@ -314,7 +314,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
     </tr>
     <tr>
       <td>target</td>
-      <td>string</td>
+      <td>string | jQuery object | DOM element</td>
       <td></td>
       <td>Specifies element to apply Scrollspy plugin.</td>
     </tr>