diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 96dd8303ecf9..cb6c5c624c8f 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -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) diff --git a/site/content/docs/4.3/components/scrollspy.md b/site/content/docs/4.3/components/scrollspy.md index 29b6468d0b8e..318a76b35dd1 100644 --- a/site/content/docs/4.3/components/scrollspy.md +++ b/site/content/docs/4.3/components/scrollspy.md @@ -324,7 +324,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap target - string + string | jQuery object | DOM element Specifies element to apply Scrollspy plugin.