fix "Cannot read property 'getAttribute' of null" error
This commit is contained in:
parent
2a7d011afd
commit
7ec607d441
1 changed files with 3 additions and 2 deletions
|
@ -3,8 +3,9 @@
|
|||
*
|
||||
* @param {String} selector
|
||||
*/
|
||||
export default (selector) => {
|
||||
const link = document.querySelector(selector).getAttribute('href');
|
||||
export default selector => {
|
||||
const element = document.querySelector(selector);
|
||||
const link = element && element.getAttribute('href');
|
||||
|
||||
if (link) {
|
||||
window.location = link;
|
||||
|
|
Loading…
Reference in a new issue