antonmedv / antonmedv/finder

[Feature Request] find path for multiple elements and find closest common parent

Aperta
#82 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
HTML
Stelle
1.5k
Fork
101
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Basically a way to find "all" of a certain element.

Feature one: Find the closest common parent. If we take a news website often times an article will involve a title, an image as well as a description. This could be something like
```

Title


Some Tag


Some Description


```
If I want to get a selector for the article, my idea would be to click ex. the title as well as the image it would return the `` path, as it's the closest parent of the given elements. In practice this would mean, you pass an array of DOM elements into a `parentFinder` function (or add an optional "mode" parameter to the finder function). who would then first traverse the DOM towards the root and then once a common ancestor is found simply call `finder` on that one

Feature two: Find multiple similar events. Again let's take the news website from Feature one. Currently finder would only return a path to the exact DOM element. This might look something like `#articles > article:nth-child(3)` for the 3rd article. I'd want a way for it to find similar elements, so ex. all `` elements within `#articles`.
I think one possible implementation would be to use Feature one, to find the wrapping container and once that is found, have an array where you need to supply one DOM element of each item you're looking for in said container, meaning it looks again for a parent path that would match each of the supplied selectors individually. Though I'm sure there has to be a better way, or even a way only requiring you to supply 2-3 examples.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.