fix "Cannot read property 'getAttribute' of null" error

This commit is contained in:
Mike Greiling 2018-04-13 01:38:19 -05:00
parent 2a7d011afd
commit 7ec607d441
No known key found for this signature in database
GPG key ID: 0303DF507FA67596

View file

@ -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;