From 2a3f741bb13f8d3a681c4f599ddfc8f2d1b1d266 Mon Sep 17 00:00:00 2001 From: Kevin Cox Date: Tue, 23 Jan 2018 21:16:19 +0000 Subject: [PATCH] Ignore dom-utils if not available. (#909) This interface was removed from Firefox without replacement. Use it if present otherwise silently do nothing. Fixes #907 --- extension/lib/utils.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 94c4e0d..fcffc81 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -4,8 +4,6 @@ nsIClipboardHelper = Cc['@mozilla.org/widget/clipboardhelper;1'] .getService(Ci.nsIClipboardHelper) -nsIDomUtils = Cc['@mozilla.org/inspector/dom-utils;1'] - .getService(Ci.inIDOMUtils) nsIEventListenerService = Cc['@mozilla.org/eventlistenerservice;1'] .getService(Ci.nsIEventListenerService) nsIFocusManager = Cc['@mozilla.org/focus-manager;1'] @@ -15,6 +13,14 @@ 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. + # For XUL, `instanceof` checks are often better than `.localName` checks, # because some of the below interfaces are extended by many elements. XULDocument = Ci.nsIDOMXULDocument @@ -494,6 +500,8 @@ setAttributes = (element, attributes) -> return setHover = (element, hover) -> + return unless nsIDomUtils + method = if hover then 'addPseudoClassLock' else 'removePseudoClassLock' while element.parentElement nsIDomUtils[method](element, ':hover') -- 2.39.3