1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-07 22:26:57 +02:00

Tab.js: Fixes on click handling (#33586)

* use prevent default only if triggered by anchor
* disable auto-initialization if trigger is disabled
This commit is contained in:
GeoSot
2021-04-20 08:26:58 +03:00
committed by GitHub
parent b59b75bc55
commit 0bbe45cd97
2 changed files with 77 additions and 55 deletions

View File

@@ -66,8 +66,7 @@ class Tab extends BaseComponent {
show() {
if ((this._element.parentNode &&
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
this._element.classList.contains(CLASS_NAME_ACTIVE)) ||
isDisabled(this._element)) {
this._element.classList.contains(CLASS_NAME_ACTIVE))) {
return
}
@@ -202,7 +201,13 @@ class Tab extends BaseComponent {
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault()
if (['A', 'AREA'].includes(this.tagName)) {
event.preventDefault()
}
if (isDisabled(this)) {
return
}
const data = Data.get(this, DATA_KEY) || new Tab(this)
data.show()