From cf0ebaaa08bc9f589c4dc2c702f94ef7b9716a2b Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Tue, 23 Jan 2018 22:21:18 +0100 Subject: [PATCH] Make nsIDOMUtils try-catch nicer --- extension/lib/utils.coffee | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index fcffc81..823ba1a 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -13,13 +13,15 @@ nsIStyleSheetService = Cc['@mozilla.org/content/style-sheet-service;1'] nsIWindowMediator = Cc['@mozilla.org/appshell/window-mediator;1'] .getService(Ci.nsIWindowMediator) -try - nsIDomUtils = Cc['@mozilla.org/inspector/dom-utils;1'] - .getService(Ci.inIDOMUtils) -catch e - # This interface was removed from Firefox with no alternative. Try to use it - # if supported but otherwise just ignore it. Code in this module handles this - # variable being undefined. +# This interface was removed from Firefox with no alternative. Try to use it if +# available but otherwise just ignore it. Code in this module handles this +# variable being `null`. +nsIDomUtils = + try + Cc['@mozilla.org/inspector/dom-utils;1'] + .getService(Ci.inIDOMUtils) + catch + null # For XUL, `instanceof` checks are often better than `.localName` checks, # because some of the below interfaces are extended by many elements. -- 2.39.3