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:
authorJohann-S <johann.servoire@gmail.com>2017-09-25 13:41:54 +0300
committerJohann-S <johann.servoire@gmail.com>2017-09-25 14:23:13 +0300
commit9b8356ba52d89fd065d6061979b5946b8c5f44fa (patch)
tree3c78f94c599eb0ba9d052742abb8e8fe5d926fba /js/src/collapse.js
parent3abf8a0e5525d30914ce37ebb98240a476cb6f17 (diff)
Collapse - Allow to pass jQuery object or DOM element to the parent option
Diffstat (limited to 'js/src/collapse.js')
-rw-r--r--js/src/collapse.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index bf9c990ecc..fa082f1333 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -33,7 +33,7 @@ const Collapse = (() => {
const DefaultType = {
toggle : 'boolean',
- parent : 'string'
+ parent : '(string|element)'
}
const Event = {
@@ -289,7 +289,18 @@ const Collapse = (() => {
}
_getParent() {
- const parent = $(this._config.parent)[0]
+ let parent = null
+ if (Util.isElement(this._config.parent)) {
+ parent = this._config.parent
+
+ // it's a jQuery object
+ if (typeof this._config.parent.jquery !== 'undefined') {
+ parent = this._config.parent[0]
+ }
+ } else {
+ parent = $(this._config.parent)[0]
+ }
+
const selector =
`[data-toggle="collapse"][data-parent="${this._config.parent}"]`