Skip to content

Commit

Permalink
fix(tabs): Allow tab hrefs to point anywhere
Browse files Browse the repository at this point in the history
* Check for '#' before proceeding with querySelector and tab state modification
* Allows anchors to point to other links

Closes #4072
  • Loading branch information
MitchLillie committed Oct 19, 2016
1 parent feca3a8 commit 14b6cb1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

}
Expand Down

0 comments on commit 14b6cb1

Please sign in to comment.