mrwweb / clicky-menus

Simple click-triggered navigation submenus. Accessible and progressively enhanced.
MIT License
90 stars 15 forks source link

Generate ID / aria-controls in a way that doesn't result in potentially invalid attribute characters #12

Open mrwweb opened 1 year ago

mrwweb commented 1 year ago

Right now, the way the ID for each submenu is generated can pull in special characters, probably including those that might be invalid. For example, here's one from a site I'm working on right now: exhibitions-|-collections-submenu. The solution is to either drop any characters other than numbers and letters or switch to something that is guaranteed to be unique. I just updated the script to ensure submenu IDs are unique per-menu (see #11), so I should probably switch to something that is also unique per-menu-item.