From e7ce3765c4a1b18894efedc2bfbec32dc9bf1009 Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Tue, 21 May 2019 12:26:46 +0200 Subject: [PATCH] fix errors in case of body is not initialized --- src/mailgo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mailgo.js b/src/mailgo.js index 7987898..fc73178 100644 --- a/src/mailgo.js +++ b/src/mailgo.js @@ -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 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 => {