aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2020-05-05 21:42:58 +0200
committerXhmikosR <[email protected]>2020-05-07 09:31:49 +0300
commit22f75ca2e328ad232dd2afafd15dc0c79a908410 (patch)
treee57daf36c9e278da5f108353e5d4000a3b2b5d53
parent5f267b1854d9fd1843ca225dc2a529f9912b4a6f (diff)
downloadbootstrap-22f75ca2e328ad232dd2afafd15dc0c79a908410.tar.xz
bootstrap-22f75ca2e328ad232dd2afafd15dc0c79a908410.zip
enforce element check on scrollspy target
-rw-r--r--js/src/scrollspy.js2
-rw-r--r--js/tests/unit/scrollspy.js2
-rw-r--r--site/docs/4.4/components/scrollspy.md2
3 files changed, 3 insertions, 3 deletions
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js
index 2c7c8a1dc..bf546a258 100644
--- a/js/src/scrollspy.js
+++ b/js/src/scrollspy.js
@@ -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)
diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js
index c311c8423..6f5c92cab 100644
--- a/js/tests/unit/scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -127,7 +127,7 @@ $(function () {
.show()
.find('#scrollspy-example')
.bootstrapScrollspy({
- target: document.getElementById('#ss-target')
+ target: document.getElementById('ss-target')
})
$scrollspy.one('scroll', function () {
diff --git a/site/docs/4.4/components/scrollspy.md b/site/docs/4.4/components/scrollspy.md
index 43443e7fb..eb5b4ba6f 100644
--- a/site/docs/4.4/components/scrollspy.md
+++ b/site/docs/4.4/components/scrollspy.md
@@ -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>