Fix createObserver() check (#2873)

This commit is contained in:
Sami Vänttinen 2026-03-03 06:48:32 +02:00 committed by GitHub
parent b01af22fd1
commit 02a3e441ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}
};