texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Mon, 7 Oct 2024 16:11:01 -0400 (EDT)

branch: master
commit 0918e44ef1f8676a1cb746e3bbf1a18c5278a9ed
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Oct 7 21:09:41 2024 +0100

    Fix info.js index lookup to go to correct location
    
    * js/info.js (cache_index_links): Save location of index anchor
    rather than just the node it is in.  This means that lookups
    of the index entry can scroll to the correct part of the node.
    Rename local variables to refer to "entries" rather than "links"
    as this is now misnamed.
    (init_sidebar): Always use result of linkid_split to update sidebar.
    
    Report and investigation by Benjamin Kalish.
---
 ChangeLog  | 13 +++++++++++++
 js/info.js | 32 +++++++++++++++-----------------
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index edb68a8c94..dd122b39d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-10-07  Gavin Smith <gavinsmith0123@gmail.com>
+
+       Fix info.js index lookup to go to correct location
+
+       * js/info.js (cache_index_links): Save location of index anchor
+       rather than just the node it is in.  This means that lookups
+       of the index entry can scroll to the correct part of the node.
+       Rename local variables to refer to "entries" rather than "links"
+       as this is now misnamed. 
+       (init_sidebar): Always use result of linkid_split to update sidebar.
+
+       Report and investigation by Benjamin Kalish.
+
 2024-10-07  Gavin Smith <gavinsmith0123@gmail.com>
 
        * doc/texinfo.texi (@cartouche): Remove statement that there is
diff --git a/js/info.js b/js/info.js
index 28f49b292c..5b11071590 100644
--- a/js/info.js
+++ b/js/info.js
@@ -147,32 +147,31 @@ var actions = {
     return { type: "cache-links", links: links };
   },
 
-  /** @arg {NodeListOf<Element>} links */
-  cache_index_links: function (links) {
+  /** @arg {NodeListOf<Element>} entries */
+  cache_index_links: function (entries) {
     var dict = {};
     var text0 = "", text1 = ""; // for subentries
-    for (var i = 0; i < links.length; i += 1)
+    for (var i = 0; i < entries.length; i += 1)
       {
-        var link = links[i];
-        var link_cl = link.classList;
-        var text = link.textContent;
-        if (link_cl.contains("index-entry-level-2"))
+        var entry = entries[i];
+        var entry_cl = entry.classList;
+        var text = entry.textContent;
+        if (entry_cl.contains("index-entry-level-2"))
           {
-              text = text0 + "; " + text1 + "; " + text;
+            text = text0 + "; " + text1 + "; " + text;
           }
-        else if (link_cl.contains("index-entry-level-1"))
+        else if (entry_cl.contains("index-entry-level-1"))
           {
             text1 = text;
-              text = text0 + "; " + text;
+            text = text0 + "; " + text;
           }
         else
           {
             text0 = text;
           }
 
-        if ((link = link.nextSibling)
-            && link.classList.contains("printindex-index-section")
-            && (link = link.firstChild))
+        var link = entry.firstChild;
+        if (link && link.nodeName == 'A')
           {
             dict[text] = href_hash (link_href (link));
           }
@@ -1457,15 +1456,14 @@ init_sidebar ()
 
         /* Remove the hash part for the main page.  */
         var pageid = linkid_split (data.selected).pageid;
-        var selected = (pageid === config.TOP_ID) ? pageid : data.selected;
-        debug ("sidebar - " + selected);
+        debug ("sidebar - " + pageid);
 
         /* Highlight the current LINKID in the table of content.  */
-        var elem = scan_toc (toc_div, selected, data.section_hash);
+        var elem = scan_toc (toc_div, pageid, data.section_hash);
         if (elem)
           elem.scrollIntoView (true);
         else
-          debug ("sidebar - no elem " + selected);
+          debug ("sidebar - no elem " + pageid);
       }
   }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]