Skip to content

Commit

Permalink
enforce element check on scrollspy target (twbs#30747)
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S authored and olsza committed Oct 3, 2020
1 parent 18be046 commit 1044bfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion js/src/scrollspy.js
Expand Up @@ -9,6 +9,7 @@ import {
getjQuery,
getSelectorFromElement,
getUID,
isElement,
typeCheckConfig
} from './util/index'
import Data from './dom/data'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/4.3/components/scrollspy.md
Expand Up @@ -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>
Expand Down

0 comments on commit 1044bfa

Please sign in to comment.