mirror of
https://github.com/google/material-design-lite.git
synced 2024-08-17 00:00:24 +03:00
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…
Reference in New Issue
Block a user