PageSourceSearch

https://semver.org/js/anchorli.js

js semver.org collected 2026-10-01 06:03:45 UTC 815 bytes, 29 lines download raw bytes

1const createAnchorLink = (id) => {
2  const anchor = document.createElement("a");
3  anchor.className = "anchor-link";
4  anchor.href = "#" + id;
5  return anchor;
6};
7
8window.onload = () => {
9  let increment = 0;
10  [...document.querySelectorAll("h1, h2, h3, #spec > ol > li > p")].forEach(
11    (el) => {
12      if (el.id) {
13        const anchorLink = createAnchorLink(el.id);
14        el.insertBefore(anchorLink, el.firstChild);
15      } else {
16        increment++;
17        el.parentElement.id = "spec-item-" + increment;
18        const anchorLink = createAnchorLink(el.parentElement.id);
19        el.parentElement.insertBefore(anchorLink, el);
20      }
21    }
22  );
23
24  const hash = window.location.hash;
25  if (hash) {
26    const targetElTop = document.querySelector(hash).offsetTop;
27    window.scrollTo(0, targetElTop);
28  }
29};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.