fix error with href=#mailgo

This commit is contained in:
Matteo Manzinello 2019-05-12 12:21:38 +02:00
parent df23910808
commit e735733099
3 changed files with 9 additions and 5 deletions

9
dist/mailgo.js vendored
View File

@ -128,6 +128,7 @@ mailgoInit = () => {
open.classList.add("mailgo-weight-500"); open.classList.add("mailgo-weight-500");
let openContent = document.createTextNode("open"); let openContent = document.createTextNode("open");
open.appendChild(openContent); open.appendChild(openContent);
modalContent.appendChild(open); modalContent.appendChild(open);
// copy // copy
@ -138,6 +139,7 @@ mailgoInit = () => {
copy.classList.add("mailgo-weight-500"); copy.classList.add("mailgo-weight-500");
let copyContent = document.createTextNode("copy"); let copyContent = document.createTextNode("copy");
copy.appendChild(copyContent); copy.appendChild(copyContent);
modalContent.appendChild(copy); modalContent.appendChild(copy);
// by // by
@ -147,6 +149,7 @@ mailgoInit = () => {
by.target = "_blank"; by.target = "_blank";
let textBy = document.createTextNode("mailgo.js.org"); let textBy = document.createTextNode("mailgo.js.org");
by.appendChild(textBy); by.appendChild(textBy);
modalContent.appendChild(by); modalContent.appendChild(by);
// add the modal at the end of the body // add the modal at the end of the body
@ -305,6 +308,8 @@ mailgoCheckRender = event => {
// check if the id=mailgo exists in the body // check if the id=mailgo exists in the body
if (!document.body.contains(getE("mailgo"))) return; if (!document.body.contains(getE("mailgo"))) return;
console.log(e.href.toLowerCase());
if ( if (
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList // first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
(e.href && (e.href &&
@ -312,7 +317,7 @@ mailgoCheckRender = event => {
!e.classList.contains("no-mailgo")) || !e.classList.contains("no-mailgo")) ||
// second case: the href=#mailgo // second case: the href=#mailgo
// TODO FIX here // TODO FIX here
(e.href && e.href.toLowerCase() === "#mailgo") || (e.href && e.getAttribute("href").toLowerCase() === "#mailgo") ||
//third case: the classList contains mailgo //third case: the classList contains mailgo
e.classList.contains("mailgo") e.classList.contains("mailgo")
) { ) {
@ -328,7 +333,7 @@ mailgoCheckRender = event => {
document.addEventListener("DOMContentLoaded", mailgoInit, false); document.addEventListener("DOMContentLoaded", mailgoInit, false);
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
document.addEventListener("click", mailgoCheckRender, false); document.body.addEventListener("click", mailgoCheckRender, false);
// validate the email with regex // validate the email with regex
validateEmail = email => { validateEmail = email => {

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -314,8 +314,7 @@ mailgoCheckRender = event => {
e.href.toLowerCase().startsWith(MAILTO) && e.href.toLowerCase().startsWith(MAILTO) &&
!e.classList.contains("no-mailgo")) || !e.classList.contains("no-mailgo")) ||
// second case: the href=#mailgo // second case: the href=#mailgo
// TODO FIX here (e.href && e.getAttribute("href").toLowerCase() === "#mailgo") ||
(e.href && e.href.toLowerCase() === "#mailgo") ||
//third case: the classList contains mailgo //third case: the classList contains mailgo
e.classList.contains("mailgo") e.classList.contains("mailgo")
) { ) {