antonmedv/finder

[feature request] Add config option to include structural/semantic elements

eoghanmurray opened this issue · 7 comments

So I'm not sure if this is out of scope for this project.

I'm not so much interested as the shortest selector, as the most meaningful one.

From that point of view, any of the following tags are interesting:
https://www.w3schools.com/html/html5_semantic_elements.asp

I'd like those to be always included in the selector if they are present in the ancestor list.

I guess these would have to be qualified if they are not unique, so article:nth-of-type(2).

Does this request make any sense or is it a different project?

I guess a similar option to always include an ancestor which has an id might also be worthwhile from a 'meaningful' point of view.

I think it’s doable

How about a separate entry point which may call finder multiple times.

So recursively do

target.closest('article,main,section....)`

And then chain together multiple calls to finder using each such ancestor as the root

?

I can code this up unless you've an easier way of achieving it in the current .parentNode walk.

Probably should be separate config options for addStructure and addIds

We can just give different penalties depending on if it is a semantic tag or not.

I still haven't wrapped my head around the penalty system ... does it completely take precedence over length-of-string?

does it completely take precedence over length-of-string

Yes. As the goal not only short, but robust.

I'm not sure if the penalties alone will suffice; I'm thinking of this proposal as being a lot more verbose, so that it would have to look right back in the hierarchy to find those significant tag names.
As I understand it the penalty system only operates on the current level and cannot be used to 'pop out' of the hierarchy to continue evaluation with more ancestors?