question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to use -nth-child as little as possible

See original GitHub issue

Hi,

I have the problem that your library falls back to something like this: :nth-child(11) > :nth-child(2) > :nth-child(1) > :nth-child(9) but what I need is a selector that goes as far as possible without using :nth-child, i.e. like this one: div#__next > div.styles__MainContent-ghnxum-0.iIIhTW > div.styles__ContainerRoot-evpclk-2.kowoAH:nth-child(9) because all the nth-child-numbers change during the pageload.

So the feature request would be to make as long selectors as possible without using nth-child. This is perfect for me but it outputs a selector matching multiple elements 😦

I have tried those configuration options for your utility but it still prefers shortness over a sustainably working selector:

whitelist: ['class', 'tag', 'id', 'attribute'],
          combineWithinSelector: true,
          combineBetweenSelectors: true,
          includeTag: true

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jribbenscommented, Feb 17, 2021

I would like this too. Also I would like to be able to say that certain selectors are basically mandatory if they are available. e.g. if a document has only one <link> element, then asking for the selector for it just returns link, which is no use at all if later on someone adds another link. Having an option something like mandatory: ["[href]", "[src]"] to require the use of those attributes if they exist would be very helpful.

0reactions
fczbkkcommented, Sep 7, 2021

@jribbens I’m closing this issue. What you describe in your comments seem to be out of scope of the original issue.

If what you describe still a thing for you, please open a new issue and describe in more detail how it should work and how the library should know when to add unnecessary parts of the selector. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nth-child - CSS-Tricks
Rather than adding a class to every fourth item (e.g. .last ), we can use :nth-child : .module:nth-child(4n) { margin-right: 0; }.
Read more >
nth-child() - CSS: Cascading Style Sheets - MDN Web Docs
Note that, in the element:nth-child() syntax, the child count includes children of any element type; but it is considered a match only if ......
Read more >
CSS nth-child for greater than and less than - Stack Overflow
In this case, . container:nth-child(2) won't select the 2nd div. container element (which has 5th content).
Read more >
CSS nth child Selectors - YouTube
When you are trying to target HTML elements in a pattern, like every second or third list item or table row, then the...
Read more >
How to use :nth-child in CSS. The - JTWay
The :nth-child pseudo-class allows to select one and more elements based on their source order.. “How to use :nth-child in CSS” is published...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found