diff options
| author | Johann-S <[email protected]> | 2017-07-18 14:22:39 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2017-08-11 15:04:07 +0300 |
| commit | 2eb1e687bd74d147145000b3971821cc890d7652 (patch) | |
| tree | dd1db86505af301e3816cfc89deb6c4e7fe20663 /js/src | |
| parent | edf90c1bc4ec7c081cdb891a7c10dfaf6b1832e7 (diff) | |
| download | bootstrap-2eb1e687bd74d147145000b3971821cc890d7652.tar.xz bootstrap-2eb1e687bd74d147145000b3971821cc890d7652.zip | |
Improve previous selector for nested tabs
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/tab.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/js/src/tab.js b/js/src/tab.js index 5e5a83118..4c3091495 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -45,6 +45,7 @@ const Tab = (($) => { DROPDOWN : '.dropdown', NAV_LIST_GROUP : '.nav, .list-group', ACTIVE : '.active', + ACTIVE_UL : '> li > .active', DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]', DROPDOWN_TOGGLE : '.dropdown-toggle', DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active' @@ -87,7 +88,8 @@ const Tab = (($) => { const selector = Util.getSelectorFromElement(this._element) if (listElement) { - previous = $.makeArray($(listElement).find(Selector.ACTIVE)) + const itemSelector = listElement.nodeName === 'UL' ? Selector.ACTIVE_UL : Selector.ACTIVE + previous = $.makeArray($(listElement).find(itemSelector)) previous = previous[previous.length - 1] } @@ -148,7 +150,13 @@ const Tab = (($) => { // private _activate(element, container, callback) { - const activeElements = callback ? $(container).children(Selector.ACTIVE) : $(container).find(Selector.ACTIVE) + let activeElements + if (container.nodeName === 'UL') { + activeElements = $(container).find(Selector.ACTIVE_UL) + } else { + activeElements = $(container).children(Selector.ACTIVE) + } + const active = activeElements[0] const isTransitioning = callback && Util.supportsTransitionEnd() |
