aboutsummaryrefslogtreecommitdiff
path: root/js/src/collapse.js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-05-13 18:17:20 +0300
committerGitHub <[email protected]>2021-05-13 18:17:20 +0300
commit6e1c9096f08ed21063fd6ba16aa998a3ac4149f9 (patch)
treef6d0ecf0ebe37529a6b5eb3c262e1d423093b6cc /js/src/collapse.js
parente376142d85e3ce0a5f5e49f3d676e419287a7292 (diff)
downloadbootstrap-6e1c9096f08ed21063fd6ba16aa998a3ac4149f9.tar.xz
bootstrap-6e1c9096f08ed21063fd6ba16aa998a3ac4149f9.zip
Move get element functionality to a helper (#33327)
Looking around on js components I found out many checks, different expressed but with same purpose. Some of them are trying to parse string to element, others, jQuery element to js simple nodeElement etc With this Pr, I am trying to give a standard way to parse an element So this pr: * Creates `getElement` helper that tries to parse an argument to element or null * Changes `isElement` to make explicit checks and return Boolean * fixes tests deficiencies
Diffstat (limited to 'js/src/collapse.js')
-rw-r--r--js/src/collapse.js11
1 files changed, 2 insertions, 9 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 1c8f53ebd..3241a7132 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -7,9 +7,9 @@
import {
defineJQueryPlugin,
+ getElement,
getSelectorFromElement,
getElementFromSelector,
- isElement,
reflow,
typeCheckConfig
} from './util/index'
@@ -272,14 +272,7 @@ class Collapse extends BaseComponent {
_getParent() {
let { parent } = this._config
- if (isElement(parent)) {
- // it's a jQuery object
- if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
- parent = parent[0]
- }
- } else {
- parent = SelectorEngine.findOne(parent)
- }
+ parent = getElement(parent)
const selector = `${SELECTOR_DATA_TOGGLE}[data-bs-parent="${parent}"]`