lcdsantos / menuspy

A JavaScript library to make navigation menus highlight the item based on currently in view section.
https://leocs.me/menuspy/
MIT License
303 stars 38 forks source link

Get element by id #2

Closed paldepind closed 7 years ago

paldepind commented 7 years ago

I have the following in my HTML

<a href="#Maybe<A>">Maybe<A></a>

It works perfectly fine. However, MenuSpy tries to use the string "#Maybe<A>" as a selector. This gives the following error:

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#Maybe<A>' is not a valid selector.

This PR fixes the issue by not using the href attribute directly as a query selector but instead stripping the leading # from it and looking for an element with that id.

paldepind commented 7 years ago

Thank your :smile: Great work on this library :+1: