From 11bc242a4ae858e554b46f3e55cefcbe75085857 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 6 Oct 2017 10:17:41 -0400 Subject: [PATCH] null checks on mutations --- src/content/notificationBar.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/content/notificationBar.js b/src/content/notificationBar.js index 6b25eb8315..f4711e3fe6 100644 --- a/src/content/notificationBar.js +++ b/src/content/notificationBar.js @@ -66,13 +66,25 @@ function observeDom() { var bodies = document.querySelectorAll('body'); - if (bodies.length > 0) { + if (bodies && bodies.length > 0) { observer = new window.MutationObserver(function (mutations) { + if (!mutations || !mutations.length) { + return; + } + var doCollect = false; 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++) { + if (!mutations[i].addedNodes[j]) { + continue; + } + var forms = mutations[i].addedNodes[j].querySelectorAll('form:not([data-bitwarden-watching])'); - if (forms.length) { + if (forms && forms.length) { doCollect = true; break; }