1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-29 23:09:05 +02:00

Collapse - Allow to pass jQuery object or DOM element to the parent option

This commit is contained in:
Johann-S
2017-09-25 12:41:54 +02:00
parent 3abf8a0e55
commit 9b8356ba52
4 changed files with 64 additions and 9 deletions

View File

@@ -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}"]`