fix(tabs): Allow tab hrefs to point anywhere
* Check for '#' before proceeding with querySelector and tab state modification * Allows anchors to point to other links Closes #4072
This commit is contained in:
parent
feca3a815a
commit
14b6cb1c52
@ -140,13 +140,15 @@
|
||||
}
|
||||
|
||||
tab.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
var href = tab.href.split('#')[1];
|
||||
var panel = ctx.element_.querySelector('#' + href);
|
||||
ctx.resetTabState_();
|
||||
ctx.resetPanelState_();
|
||||
tab.classList.add(ctx.CssClasses_.ACTIVE_CLASS);
|
||||
panel.classList.add(ctx.CssClasses_.ACTIVE_CLASS);
|
||||
if (tab.getAttribute('href').charAt(0) === '#') {
|
||||
e.preventDefault();
|
||||
var href = tab.href.split('#')[1];
|
||||
var panel = ctx.element_.querySelector('#' + href);
|
||||
ctx.resetTabState_();
|
||||
ctx.resetPanelState_();
|
||||
tab.classList.add(ctx.CssClasses_.ACTIVE_CLASS);
|
||||
panel.classList.add(ctx.CssClasses_.ACTIVE_CLASS);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user