LP#1646166 Hatch extension load-time sanity check
authorBill Erickson <berickxx@gmail.com>
Thu, 8 Dec 2016 21:26:51 +0000 (16:26 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 16 Feb 2017 20:26:18 +0000 (15:26 -0500)
Avoid unnecessary JS errors by preventing any attempts to link the
extension to the page via document.body when (in rare cases)
document.body is null.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
extension/app/content.js

index 07ce8b7..d9c70b4 100644 (file)
 
 console.debug('Loading Hatch relay content script');
 
-// Tell the page DOM we're here.
-document.body.setAttribute('hatch-is-open', '4-8-15-16-23-42');
+// document.body can be null in rare cases, e.g. quick page reload.
+if (document.body) {
+
+    // Tell the page DOM we're here.
+    document.body.setAttribute('hatch-is-open', '4-8-15-16-23-42');
+}
 
 /**
  * Open a port to our extension.