From f989ecd48a6436dbc3ffabc8551be0ffda5cfae8 Mon Sep 17 00:00:00 2001 From: Moritz Strohm Date: Fri, 2 Dec 2022 14:28:28 +0100 Subject: re-added check for selectors --- resources/assets/javascripts/lib/skip_links.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/assets/javascripts/lib/skip_links.js b/resources/assets/javascripts/lib/skip_links.js index d066ef2..e2dee05 100644 --- a/resources/assets/javascripts/lib/skip_links.js +++ b/resources/assets/javascripts/lib/skip_links.js @@ -73,8 +73,14 @@ const SkipLinks = { } else { fragment = document.location.hash; } + let valid_selector = undefined; + try { + valid_selector = document.querySelector(fragment) != null; + } catch (e) { + valid_selector = false; + } - if (fragment.length > 0 && jQuery(fragment).length > 0) { + if (fragment.length > 0 && fragment !== SkipLinks.activeElement && valid_selector) { SkipLinks.moveSkipLinkNavigationOut(); if (jQuery(fragment).is(':focusable')) { jQuery(fragment).click().focus(); -- cgit v1.0