From 0e8443268897964d1d96685d07201f0f9b6acfd7 Mon Sep 17 00:00:00 2001 From: Will Pike Date: Tue, 16 Feb 2021 19:26:37 -0800 Subject: [PATCH] adds shadowdom support --- wx-src/content.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wx-src/content.js b/wx-src/content.js index e03c2db1..69c7777b 100644 --- a/wx-src/content.js +++ b/wx-src/content.js @@ -22,7 +22,7 @@ function handleRequestNewClipping(aRequest) return rv; } - let activeElt = window.document.activeElement; + let activeElt = getActiveElt(); log("Clippings/wx::content.js: handleRequestNewClipping(): activeElt = " + (activeElt ? activeElt.toString() : "???")); @@ -105,7 +105,7 @@ function handleRequestInsertClipping(aRequest) let clippingText = aRequest.content; let htmlPaste = aRequest.htmlPaste; let autoLineBrk = aRequest.autoLineBreak; - let activeElt = window.document.activeElement; + let activeElt = getActiveElt(); log("Clippings/wx::content.js: handleRequestInsertClipping(): activeElt = " + (activeElt ? activeElt.toString() : "???")); @@ -242,6 +242,16 @@ function isGoogleChrome() return rv; } +function getActiveElt() { + let activeElt = window.document.activeElement; + + if (!!activeElt && !!activeElt.shadowRoot) { + activeElt = activeElt.shadowRoot.activeElement; + } + + return activeElt; +} + function init() {