From a80fd2e5bd716ca94bd1a49f87f1f66057d9f0c6 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Thu, 29 Jul 2021 15:13:59 +0200 Subject: [PATCH] Fix onclick listeners for non- elements --- lib/shareon.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/shareon.js b/lib/shareon.js index 3a5d4e3..e81643d 100644 --- a/lib/shareon.js +++ b/lib/shareon.js @@ -103,11 +103,9 @@ const shareon = () => { child.setAttribute('rel', 'noopener noreferrer'); child.setAttribute('target', '_blank'); } else { - const getButtonListener = (buttonUrl) => () => { - window.open(buttonUrl, '_blank', 'noopener,noreferrer'); + child.onclick = () => { + window.open(url, '_blank', 'noopener,noreferrer'); }; - - child.addEventListener('click', getButtonListener(url)); } break; // once a network is detected we don't want to check further