Adjust regex to match `nth-*` pseudo-class element strings
See original GitHub issueDescribe 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
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:
- Created 2 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is fixed by https://github.com/styled-components/vscode-styled-components/commit/d8bbfe3039111153e44b24a8b9331d8391636391
I fixed it by comparing VSCode’s CSS syntax rules for nth-child with ours
Sorry, couldn’t get into it so far. If anyone is able to catch up on this, feel free!