Merge pull request #1049 from keepassxreboot/fix/add_extra_checks_for_document_body

Add extra checks for document.body
This commit is contained in:
Sami Vänttinen 2020-10-22 13:24:26 +03:00 committed by GitHub
commit c5e6471a08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -1588,7 +1588,8 @@ kpxcObserverHelper.ignoredElement = function(target) {
// Ignores all nodes that doesn't contain elements
// Also ignore few Youtube-specific custom nodeNames
kpxcObserverHelper.ignoredNode = function(target) {
if (kpxcObserverHelper.ignoredNodeTypes.some(e => e === target.nodeType)
if (!target
||kpxcObserverHelper.ignoredNodeTypes.some(e => e === target.nodeType)
|| kpxcObserverHelper.ignoredNodeNames.some(e => e === target.nodeName)
|| target.nodeName.startsWith('YTMUSIC')
|| target.nodeName.startsWith('YT-')) {
@ -1647,7 +1648,9 @@ kpxcObserverHelper.initObserver = async function() {
}
});
kpxc.observer.observe(document.body, kpxcObserverHelper.observerConfig);
if (document.body) {
kpxc.observer.observe(document.body, kpxcObserverHelper.observerConfig);
}
};
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

View file

@ -55,10 +55,13 @@ class Icon {
}
const kpxcUI = {};
kpxcUI.bodyRect = document.body.getBoundingClientRect();
kpxcUI.bodyStyle = getComputedStyle(document.body);
kpxcUI.mouseDown = false;
if (document.body) {
kpxcUI.bodyRect = document.body.getBoundingClientRect();
kpxcUI.bodyStyle = getComputedStyle(document.body);
}
// Wrapper for creating elements
kpxcUI.createElement = function(type, classes, attributes, textContent) {
const element = document.createElement(type);