From 953343e6632485391d6d0e8f0af288629e97422b Mon Sep 17 00:00:00 2001 From: Denis <46321706+denistol@users.noreply.github.com> Date: Wed, 2 Mar 2022 14:16:04 +0200 Subject: [PATCH] Fixed mouse event error (TypeError: e.target.closest is not a function) (#355) --- src/content/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/index.js b/src/content/index.js index 95c76ed..2b67d15 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -28,7 +28,7 @@ const handleMouseUp = async e => { const isInPasswordField = e.target.tagName === "INPUT" && e.target.type === "password"; if (isInPasswordField) return; - const inCodeElement = e.target.tagName === "CODE" || !!e.target.closest("code"); + const inCodeElement = e.target.tagName === "CODE" || (!!e.target.closest && !!e.target.closest("code")); if (inCodeElement && getSettings("isDisabledInCodeElement")) return; const isInThisElement = @@ -41,7 +41,7 @@ const handleMouseUp = async e => { const ignoredDocumentLang = getSettings("ignoredDocumentLang").split(",").map(s => s.trim()).filter(s => !!s); if (ignoredDocumentLang.length) { const ignoredLangSelector = ignoredDocumentLang.map(lang => `[lang="${lang}"]`).join(',') - if (!!e.target.closest(ignoredLangSelector)) return; + if (!!e.target.closest && !!e.target.closest(ignoredLangSelector)) return; } const selectedText = getSelectedText();