null checks on mutations
This commit is contained in:
parent
d4cf0fe338
commit
11bc242a4a
|
@ -66,13 +66,25 @@
|
||||||
|
|
||||||
function observeDom() {
|
function observeDom() {
|
||||||
var bodies = document.querySelectorAll('body');
|
var bodies = document.querySelectorAll('body');
|
||||||
if (bodies.length > 0) {
|
if (bodies && bodies.length > 0) {
|
||||||
observer = new window.MutationObserver(function (mutations) {
|
observer = new window.MutationObserver(function (mutations) {
|
||||||
|
if (!mutations || !mutations.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var doCollect = false;
|
var doCollect = false;
|
||||||
for (var i = 0; i < mutations.length; i++) {
|
for (var i = 0; i < mutations.length; i++) {
|
||||||
|
if (!mutations[i].addedNodes || !mutations[i].addedNodes.length) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
|
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
|
||||||
|
if (!mutations[i].addedNodes[j]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var forms = mutations[i].addedNodes[j].querySelectorAll('form:not([data-bitwarden-watching])');
|
var forms = mutations[i].addedNodes[j].querySelectorAll('form:not([data-bitwarden-watching])');
|
||||||
if (forms.length) {
|
if (forms && forms.length) {
|
||||||
doCollect = true;
|
doCollect = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue