]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
enforce element check on scrollspy target (#30747)
authorJohann-S <johann.servoire@gmail.com>
Wed, 6 May 2020 04:30:43 +0000 (06:30 +0200)
committerGitHub <noreply@github.com>
Wed, 6 May 2020 04:30:43 +0000 (07:30 +0300)
js/src/scrollspy.js
site/content/docs/4.3/components/scrollspy.md

index 96dd8303ecf96ca3a7922321118a77ad337f592e..cb6c5c624c8f30553a3f0ad3b8b1fdc9d7966d5f 100644 (file)
@@ -9,6 +9,7 @@ import {
   getjQuery,
   getSelectorFromElement,
   getUID,
+  isElement,
   typeCheckConfig
 } from './util/index'
 import Data from './dom/data'
@@ -168,7 +169,7 @@ class ScrollSpy {
       ...typeof config === 'object' && config ? config : {}
     }
 
-    if (typeof config.target !== 'string') {
+    if (typeof config.target !== 'string' && isElement(config.target)) {
       let { id } = config.target
       if (!id) {
         id = getUID(NAME)
index 29b6468d0b8ed442b4b7ba27e87e857a5aa527d7..318a76b35dd1a435a0c7a0218d0c501b56e10b18 100644 (file)
@@ -324,7 +324,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>