Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2021-05-13 18:17:20 +0300
committerGitHub <noreply@github.com>2021-05-13 18:17:20 +0300
commit6e1c9096f08ed21063fd6ba16aa998a3ac4149f9 (patch)
treef6d0ecf0ebe37529a6b5eb3c262e1d423093b6cc /js/src/collapse.js
parente376142d85e3ce0a5f5e49f3d676e419287a7292 (diff)
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 1c8f53ebd6..3241a71327 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}"]`