From 02a3e441ba841423dd8f9ee62b6f2e6247bd8af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20V=C3=A4nttinen?= Date: Tue, 3 Mar 2026 06:48:32 +0200 Subject: [PATCH] Fix createObserver() check (#2873) --- keepassxc-browser/content/ui.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/keepassxc-browser/content/ui.js b/keepassxc-browser/content/ui.js index 46c07fd..fbec8c6 100644 --- a/keepassxc-browser/content/ui.js +++ b/keepassxc-browser/content/ui.js @@ -13,6 +13,12 @@ const ORANGE_BUTTON = 'kpxc-button kpxc-orange-button'; const RED_BUTTON = 'kpxc-button kpxc-red-button'; const GRAY_BUTTON_CLASS = 'kpxc-gray-button'; +const ALLOWED_OBSERVER_NODETYPES = [ + Node.ELEMENT_NODE, + Node.DOCUMENT_NODE, + Node.DOCUMENT_FRAGMENT_NODE +]; + const OBSERVER_OPTIONS = { attributes: true, attributeFilter: [ 'style' ] }; const DatabaseState = { @@ -263,10 +269,10 @@ kpxcUI.createPageObserver = function() { } }); - if (document?.documentElement) { + if (document?.documentElement && ALLOWED_OBSERVER_NODETYPES.includes(document.documentElement.nodeType)) { kpxcUI.pageObserver.observe(document.documentElement, OBSERVER_OPTIONS); } - if (document?.body) { + if (document?.body && ALLOWED_OBSERVER_NODETYPES.includes(document.body.nodeType)) { kpxcUI.pageObserver.observe(document.body, OBSERVER_OPTIONS); } };