mod/bootstrap/vendor/bootstrap/js/src/tab.js in card-1.93.2 vs mod/bootstrap/vendor/bootstrap/js/src/tab.js in card-1.93.3

- old
+ new

@@ -1,26 +1,27 @@ +import $ from 'jquery' import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-beta): tab.js + * Bootstrap (v4.0.0-beta.2): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -const Tab = (($) => { +const Tab = (() => { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'tab' - const VERSION = '4.0.0-beta' + const VERSION = '4.0.0-beta.2' const DATA_KEY = 'bs.tab' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' const JQUERY_NO_CONFLICT = $.fn[NAME] const TRANSITION_DURATION = 150 @@ -43,10 +44,11 @@ const Selector = { 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' } @@ -85,11 +87,12 @@ let previous const listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0] 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] } const hideEvent = $.Event(Event.HIDE, { relatedTarget: this._element @@ -146,11 +149,18 @@ // private _activate(element, container, callback) { - const active = $(container).find(Selector.ACTIVE)[0] + 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() && (active && $(active).hasClass(ClassName.FADE)) const complete = () => this._transitionComplete( @@ -184,15 +194,19 @@ if (dropdownChild) { $(dropdownChild).removeClass(ClassName.ACTIVE) } - active.setAttribute('aria-expanded', false) + if (active.getAttribute('role') === 'tab') { + active.setAttribute('aria-selected', false) + } } $(element).addClass(ClassName.ACTIVE) - element.setAttribute('aria-expanded', true) + if (element.getAttribute('role') === 'tab') { + element.setAttribute('aria-selected', true) + } if (isTransitioning) { Util.reflow(element) $(element).addClass(ClassName.SHOW) } else { @@ -227,11 +241,11 @@ data = new Tab(this) $this.data(DATA_KEY, data) } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() } }) @@ -266,8 +280,8 @@ return Tab._jQueryInterface } return Tab -})(jQuery) +})($) export default Tab