Language: TypeScript
Label: vulnerable
CWE: NVD-CWE-noinfo \u2014 

Code:
    const onHeadingsChanged = () => {
      if (!this.parser) {
        return;
      }

      // Clear all numbering items
      TableOfContentsUtils.clearNumbering(widget.content.node);

      // Create a new mapping
      headingToElement = new WeakMap<IMarkdownViewerHeading, Element | null>();
      model.headings.forEach(async heading => {
        const elementId = await TableOfContentsUtils.Markdown.getHeadingId(
          this.parser!,
          heading.raw,
          heading.level
        );

        if (!elementId) {
          return;
        }
        const selector = `h${heading.level}[id="${elementId}"]`;

        headingToElement.set(
          heading,
          TableOfContentsUtils.addPrefix(
            widget.content.node,
            selector,
            heading.prefix ?? ''
          )
        );
      });
    };