dexterouslogic / super-simple-highlighter

A chrome extension which highlights text on a web page, and attempts to restore it on returning
GNU General Public License v3.0
144 stars 55 forks source link

Bug: Highlighting doesn't work in elements whose ID is a number #18

Open Benna96 opened 2 years ago

Benna96 commented 2 years ago

Highlighting wasn't working on the content of a page. Took a look at console. Saw a bunch of the following errors: Error in event handler: Error: Failed to execute 'querySelectorAll' on 'Document': '#3548247' is not a valid selector.

This is the page I noticed it at, for reference. The description at the top can be highlighted just fine, however, highlighting anything within the actual guide doesn't work.

The problem is in js/shared/utils.js, line 287. Googled a bit, it seems numerical IDs should be valid with HTML5, but require special handling when used with QuerySelector, as using the # selector with them causes them to not be valid CSS selectors... Perhaps querySelectorAll(`#${node.id}`) could be changed to querySelectorAll(`id="${node.id}"`)?