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.

Adjust regex to match `nth-*` pseudo-class element strings

See original GitHub issue

Describe the bug As the title described, it would be nice if the regex could also catch the strings provided in strings in pseudo classes. Such as nth-child(), :nth-last-child(), :nth-of-type(), :nth-last-of-type(). At the moment, the string doesn’t get recognized properly as in normal CSS.

const Listing = styled.div`
  margin-top: calc(var(--rowGap)*1.5);

  div:nth-last-of-type(2n) {
    margin: 0 auto;
  }

  ${media.lessThan('medium')`
    r-grid {
      grid-row-gap: calc(var(--rowGap) / 2);

      r-cell:nth-child(2n+1) {
        margin-bottom: calc(var(--rowGap) / 2);
      }
    }
  `}
`

Screenshot Bildschirmfoto 2021-05-01 um 14 22 46

To Reproduce

const Listing = styled.div`
  margin-top: calc(var(--rowGap)*1.5);

  div:nth-last-of-type(2n) {
    margin: 0 auto;
  }

  ${media.lessThan('medium')`
    r-grid {
      grid-row-gap: calc(var(--rowGap) / 2);

      r-cell:nth-child(2n+1) {
        margin-bottom: calc(var(--rowGap) / 2);
      }
    }
  `}
`

Expected behavior The string in the pseudo class function should highlight in one color, at the moment only the first number is highlighted.

Build environment:

  • OS: MacOS Catalina 10.15.7
  • VSCode Version: 1.55.2
  • Extension Version: v1.5.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
jasonwilliamscommented, Jul 25, 2021
0reactions
felixhaeberlecommented, May 20, 2021

Sorry, couldn’t get into it so far. If anyone is able to catch up on this, feel free!

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Call for ::nth-everything - CSS-Tricks
With CSS3, we have positional pseudo class selectors to help us select specific elements when there are no other distinguishing ...
Read more >
How to remove all pseudo selectors from a CSS selector string ...
You can remove them with a regular expression and replace : selector = selector.replace(/::?[^ ,:.]+/g, '');.
Read more >
Selectors - W3C
In CSS, pattern matching rules determine which style rules apply to elements in the document tree. These patterns, called selectors, may range from...
Read more >
selector-pseudo-class-allowed-list - Stylelint
Specify a list of allowed pseudo-class selectors. ... This rule ignores selectors that use variable interpolation e.g. :#{$variable} {} . Options​. array|string| ...
Read more >
Element selectors | Playwright
Selectors are strings that point to the elements in the page. ... The :visible pseudo-class in CSS selectors matches the elements that are...
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