All files / public/details index.ts

92.59% Statements 25/27
57.89% Branches 11/19
100% Functions 3/3
92.59% Lines 25/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58        1x 5x   5x     5x 5x     5x 5x 5x 2x     2x 2x     2x 2x 2x       5x 2x   2x       2x 2x         5x 5x 5x     5x     5x 5x          
import { HistoryState } from "./historyState";
import { TableOfContents } from "./tableOfContents";
import { channelMap } from "./channelMap";
 
const init = (packageName: string) => {
  const historyState = new HistoryState();
 
  const configurationEl = document.querySelector<HTMLElement>(
    "[data-js='configuration']"
  );
  Eif (configurationEl) {
    new TableOfContents(configurationEl, historyState);
  }
 
  const actions = document.querySelector("[data-js='actions']");
  Eif (actions) {
    const toggleAccordion = (button: HTMLElement) => {
      const controls = button.parentElement!.querySelector<HTMLElement>(
        `#${button.getAttribute("aria-controls")}`
      );
      let show = true;
      Iif (button.getAttribute("aria-expanded") === "true") {
        show = false;
      }
      button.setAttribute("aria-expanded", show.toString());
      Eif (controls) {
        controls.setAttribute("aria-hidden", (!show).toString());
      }
    };
 
    actions.addEventListener("click", (e: Event) => {
      let target = e.target as HTMLElement;
 
      while (target && !target.hasAttribute("role") && target.parentElement) {
        target = target.parentElement as HTMLElement;
      }
 
      Eif (target && target.getAttribute("role") === "tab") {
        toggleAccordion(target);
      }
    });
  }
 
  const docsEl = document.querySelector<HTMLElement>("[data-js='docs']");
  Eif (docsEl) {
    new TableOfContents(docsEl, historyState);
  }
 
  const channelMapButton = document.querySelector<HTMLElement>(
    "[data-js='channel-map']"
  );
  Eif (channelMapButton) {
    channelMap(packageName, channelMapButton);
  }
};
 
export { init };