This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/master by this push:
     new d34094f56 [#8582] avoid bad selector errors
d34094f56 is described below

commit d34094f56b27f7dee899ea5e6d33ac79cf560311
Author: Dave Brondsema <dbronds...@slashdotmedia.com>
AuthorDate: Thu Aug 21 17:25:25 2025 -0400

    [#8582] avoid bad selector errors
---
 Allura/allura/public/nf/js/allura-base.js | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Allura/allura/public/nf/js/allura-base.js 
b/Allura/allura/public/nf/js/allura-base.js
index 54aabdf56..26abee4b4 100644
--- a/Allura/allura/public/nf/js/allura-base.js
+++ b/Allura/allura/public/nf/js/allura-base.js
@@ -242,13 +242,17 @@ $(function(){
     // backwards compatibility for old anchors.  If there's an intended 
target, but not an active one, try again with TOC prefix
     if (window.location.hash && !document.querySelector(':target')) {
         var new_hash = window.location.hash.replace('#', '#h-');
-        if (document.querySelector(new_hash)) {
-            window.location.hash = new_hash;
-        } else {
-            new_hash = window.location.hash.replace('#', '#user-content-');
+        try {
             if (document.querySelector(new_hash)) {
                 window.location.hash = new_hash;
+            } else {
+                new_hash = window.location.hash.replace('#', '#user-content-');
+                if (document.querySelector(new_hash)) {
+                    window.location.hash = new_hash;
+                }
             }
+        } catch (e) {
+            // e.g. invalid selector syntax
         }
     }
 });

Reply via email to