1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-11 08:04:59 +02:00

Improve previous selector for nested tabs

This commit is contained in:
Johann-S
2017-07-18 14:22:39 +02:00
committed by XhmikosR
parent edf90c1bc4
commit 2eb1e687bd
2 changed files with 18 additions and 9 deletions

View File

@@ -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()