mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
Improve previous selector for nested tabs
This commit is contained in:
parent
edf90c1bc4
commit
2eb1e687bd
@ -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()
|
||||
|
@ -182,13 +182,14 @@ $(function () {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
|
||||
var dropHTML = '<ul class="drop nav">'
|
||||
+ '<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>'
|
||||
+ '<ul class="dropdown-menu">'
|
||||
+ '<li><a href="#1-1" data-toggle="tab">1-1</a></li>'
|
||||
+ '<li><a href="#1-2" data-toggle="tab">1-2</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</li>'
|
||||
var dropHTML =
|
||||
'<ul class="drop nav">'
|
||||
+ ' <li class="dropdown"><a data-toggle="dropdown" href="#">1</a>'
|
||||
+ ' <ul class="dropdown-menu nav">'
|
||||
+ ' <li><a href="#1-1" data-toggle="tab">1-1</a></li>'
|
||||
+ ' <li><a href="#1-2" data-toggle="tab">1-2</a></li>'
|
||||
+ ' </ul>'
|
||||
+ ' </li>'
|
||||
+ '</ul>'
|
||||
|
||||
$(dropHTML)
|
||||
|
Loading…
Reference in New Issue
Block a user