Skip to content

Page Anchor links do not have a discernable name #21

@jenweber

Description

@jenweber

This markup causes a "links do not have a discernable name" error:

<h3 id="toc_introducing-ember-objects" class="anchorable-toc">
   Introducing: Ember Objects
   <a class="toc-anchor" href="#toc_introducing-ember-objects"></a>
</h3>

Screen Shot 2019-06-26 at 6 35 19 PM

This fix below works to put the text inside a link, but shipping it requires changes to styling. Since the headers become proper links, they need work to make them look like normal headers again.

In guides-article.js:

    for (var element of allHeaders) {
      if (element.id) {
        element.className = 'anchorable-toc'
        let link = document.createElement('a');
        link.className = 'toc-anchor';
        link.href = `#${element.id}`;
        link.innerText = element.textContent;
        element.innerText = '';
        element.appendChild(link, element.firstElementChild);
      }
    }

Results in

<h2 id="some-text" class="anchorable-toc"><a class="toc-anchor" href="#sometext">Some Text</a></h2>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions