fix errors in case of body is not initialized

This commit is contained in:
Matteo Manzinello 2019-05-21 12:26:46 +02:00
parent 23493532c1
commit e7ce3765c4
1 changed files with 2 additions and 2 deletions

View File

@ -364,7 +364,7 @@ const mailgoCheckRender = event => {
let e = event.target;
// check if the id=mailgo exists in the body
if (!document.body.contains(getE("mailgo"))) return;
if (!document.contains(getE("mailgo"))) return;
if (
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
@ -425,7 +425,7 @@ const mailgoKeydown = (mail, url, mailtoHref, encEmail, copyButton) => {
document.addEventListener("DOMContentLoaded", mailgoInit, false);
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
document.body.addEventListener("click", mailgoCheckRender, true);
document.addEventListener("click", mailgoCheckRender, true);
// validate the email with regex
const validateEmail = email => {