Skip to content

Commit

Permalink
enforce element check on scrollspy target
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S authored and XhmikosR committed May 7, 2020
1 parent 5f267b1 commit 22f75ca
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion js/tests/unit/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ $(function () {
.show()
.find('#scrollspy-example')
.bootstrapScrollspy({
target: document.getElementById('#ss-target')
target: document.getElementById('ss-target')
})

$scrollspy.one('scroll', function () {
Expand Down
2 changes: 1 addition & 1 deletion site/docs/4.4/components/scrollspy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 22f75ca

Please sign in to comment.