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
|
* @param {String} selector
|
||||||
*/
|
*/
|
||||||
export default (selector) => {
|
export default selector => {
|
||||||
const link = document.querySelector(selector).getAttribute('href');
|
const element = document.querySelector(selector);
|
||||||
|
const link = element && element.getAttribute('href');
|
||||||
|
|
||||||
if (link) {
|
if (link) {
|
||||||
window.location = link;
|
window.location = link;
|
||||||
|
|
Loading…
Reference in a new issue