From a4e5da9d0d3cd37ed6339ca5151c7bc4daa67f87 Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 27 Dec 2019 02:09:05 +0100 Subject: [PATCH] Remove last isXULDocument() references == commands.follow == On XUL pages/windows, does not exist (hence the check was put in), but is `null`, so can be safely compared against (and the check can be omitted). == helper_follow == Since the last war on isXULDocument, the namespace has in many cases been moved from the document root to a descendant (e.g. to on about:preferences in fx73). This means that the isXULDocument call often isn't triggered when it should. Coincidentally, most XULElements are recognized, either due to them being implemented as a custom element containing a recognized element or by their tag name being identical to a recognized one. The only exception is , which needed special handling in commands.follow_in_tab(). --- extension/lib/commands-frame.coffee | 11 ++++------- extension/lib/utils.coffee | 5 +---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/extension/lib/commands-frame.coffee b/extension/lib/commands-frame.coffee index 9746788..7ed9308 100644 --- a/extension/lib/commands-frame.coffee +++ b/extension/lib/commands-frame.coffee @@ -139,8 +139,6 @@ commands.scroll_to_position = (args) -> helper_follow = (options, matcher, {vim, pass}) -> {id, combine = true, selectors = FOLLOW_DEFAULT_SELECTORS} = options - if utils.isXULDocument(vim.content.document) - selectors = ['*'] if pass == 'auto' pass = if selectors.length == 2 then 'first' else 'single' @@ -300,10 +298,9 @@ commands.follow = helper_follow.bind( type = 'clickable' # Last resort checks for elements that might be clickable because of # JavaScript. - when (not utils.isXULDocument(document) and - # It is common to listen for clicks on `` or ``. Don’t - # waste time on them. - element not in [document.documentElement, document.body]) and + # It is common to listen for clicks on `` or ``. Don’t + # waste time on them. + when element not in [document.documentElement, document.body] and (utils.includes(element.className, 'button') or utils.includes(element.getAttribute?('aria-label'), 'close') or # Do this last as it’s a potentially expensive check. @@ -327,7 +324,7 @@ commands.follow = helper_follow.bind( ) commands.follow_in_tab = helper_follow.bind( - null, {id: 'tab', selectors: ['a']}, + null, {id: 'tab', selectors: ['a', 'label[is="text-link"]']}, ({element}) -> type = if isProperLink(element) then 'link' else null return type diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 9ed48e9..2e2b72f 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -37,10 +37,8 @@ getDocument = (e) -> if e.parentNode? then arguments.callee(e.parentNode) else e isInShadowRoot = (element) -> ShadowRoot? and getDocument(element) instanceof ShadowRoot -XUL_NS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' -isXULDocument = (doc) -> - doc.documentElement.namespaceURI == XUL_NS isXULElement = (element) -> + XUL_NS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' element.namespaceURI == XUL_NS # Full chains of events for different mouse actions. Note: 'click' is fired @@ -752,7 +750,6 @@ module.exports = { isProperLink isTextInputElement isTypingElement - isXULDocument isXULElement isInShadowRoot -- 2.39.3