This commit is contained in:
Matteo Manzinello 2019-05-24 10:32:02 +02:00
parent 6d81e1debd
commit dab541edaa
3 changed files with 37 additions and 31 deletions

10
dist/mailgo.js vendored
View File

@ -265,11 +265,10 @@ var actions = {
*/ */
var mailgoCheckRender = function mailgoCheckRender(event) { var mailgoCheckRender = function mailgoCheckRender(event) {
// the target element // check if the id=mailgo exists in the body
var e = event.target; // check if the id=mailgo exists in the body if (!document.contains(getE("mailgo"))) return; // go in the event.path to find if the user has clicked on a mailgo element
if (!document.contains(getE("mailgo"))) return;
event.path.forEach(function (e) {
if ( // first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList if ( // first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
e.href && e.href.toLowerCase().startsWith(MAILTO) && !e.classList.contains("no-mailgo") || // second case: the href=#mailgo e.href && e.href.toLowerCase().startsWith(MAILTO) && !e.classList.contains("no-mailgo") || // second case: the href=#mailgo
e.href && e.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo e.href && e.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo
@ -278,7 +277,10 @@ var mailgoCheckRender = function mailgoCheckRender(event) {
event.preventDefault(); // render mailgo event.preventDefault(); // render mailgo
mailgoRender(e); mailgoRender(e);
return;
} }
});
return;
}; };
/** /**
* mailgoKeydown * mailgoKeydown

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -328,12 +328,11 @@ const actions = {
* ); * );
*/ */
const mailgoCheckRender = event => { const mailgoCheckRender = event => {
// the target element
let e = event.target;
// check if the id=mailgo exists in the body // check if the id=mailgo exists in the body
if (!document.contains(getE("mailgo"))) return; if (!document.contains(getE("mailgo"))) return;
// go in the event.path to find if the user has clicked on a mailgo element
event.path.forEach(e => {
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 &&
@ -349,7 +348,12 @@ const mailgoCheckRender = event => {
// render mailgo // render mailgo
mailgoRender(e); mailgoRender(e);
return;
} }
});
return;
}; };
/** /**