matrix-org / matrix-spec

The Matrix protocol specification
Apache License 2.0
197 stars 97 forks source link

Fix error in ToC script at the bottom of the page #2002

Closed zecakeh closed 2 days ago

zecakeh commented 4 days ago

It didn't account for the case where there is no visible heading at the bottom of the page.

The error should be easy to reproduce in the current unstable spec, by navigating to the very bottom of the CS spec. A bunch or errors should appear in the console log.

Pull Request Checklist

Preview: https://pr2002--matrix-spec-previews.netlify.app

richvdh commented 2 days ago

Indeed. Error is:

22:04:08.829 Uncaught TypeError: heading is null
    onScroll https://spec.matrix.org/unstable/js/toc.js:155
    throttle https://spec.matrix.org/unstable/js/toc.js:39
    EventListener.handleEvent* https://spec.matrix.org/unstable/js/toc.js:162
    EventListener.handleEvent* https://spec.matrix.org/unstable/js/toc.js:147
toc.js:155:20

This was presumably introduced by https://github.com/matrix-org/matrix-spec/pull/1991.