"click", function() {
          window.closeTocIfSmallScreen();
        });

      // When the window is small (toc is on top of content), clicking a link
      // in the toc should toggle the toc.
      tocEl.addEventListener("click", function(ev) {
        if (!isSmallScreen.matches) return;
        if (ev.target.nodeName.toLowerCase() !== "a") return;

        toggleToc();
      });

      toggleTocEl.addEventListener("click", toggleToc);
    };
  </script>
</body>
</html>
