Use plain JS within `clickTab`, make comment more concise

This commit is contained in:
Kushal Pandya 2017-02-07 11:22:52 +05:30
parent f9c23de6de
commit ef99b5e896
1 changed files with 10 additions and 4 deletions

View File

@ -102,10 +102,16 @@ require('./flash');
}
clickTab(e) {
const targetLink = $(e.target).attr('href');
if (e.metaKey || e.ctrlKey || e.which === 2) {
e.stopImmediatePropagation();
window.open(targetLink, '_blank');
if (e.target) {
const targetLink = e.target.getAttribute('href');
// Allow following special clicks to make link open in new tab
// 1) Cmd + Click on Mac (e.metaKey)
// 2) Ctrl + Click on PC (e.ctrlKey)
// 3) Middle-click or Mouse Wheel Click (e.which is 2)
if (e.metaKey || e.ctrlKey || e.which === 2) {
e.stopImmediatePropagation();
window.open(targetLink, '_blank');
}
}
}