antonmedv/finder

Duplicate IDs will cause Finder to throw an error and not return a selector

conormaguire opened this issue ยท 2 comments

Hi there ๐Ÿ‘‹

I've run into a bug where finder will throw an error if two elements on the same page have the same ID. This is the error being thrown:

throw new Error(`Selector was not found.`)

Very small reproducible example:

<h1 id="duplicate_id">This ID is not unique</h1>
<h1 id="duplicate_id" >This ID is not unique either</h1>

Maybe an unoptimized selector could be returned instead here?

Id in page should be unique. Finder checks it here:

if (unique(candidate)) {

And fails. Some workaround for non-uniq id should be implemented. Can somebody try to fix it?

Fixed! Now works with duplicates!