You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
utils.reduceCSSSelector() does wrong things. Yep, you can remove pseudos classes like :hover, :focus and pseudo elements from a selector, but there are pseudos like :not(), :empty, :nth-child() etc that change the meaning of selector. Another problem that part of selector after any pseudo is cutting, e.g. "a:hover img" -> "a" so if there is no any img inside a the rule is still preserved. On the one hand, that's not a big dial, because you just left more rules that needed. On the other hand, this tool tries extract as minimal CSS as possible, so I think it should be fixed. Unfortunately, this is a complex problem so I left it as is at the moment. I let you know, when I found a better solution.
@lahmatiy Recommended we hang tight till a better solution becomes available. One, ideally based on AST instead of some hopeful regex juggling.
We might want to consider a partial improvement that'll solve some of the easier things to tackle. For example, we can maintain a white list of pseudo selectors that are valid/important and works with cheerio. E.g. :not.
Another partial improvement is to split the selector by spaces, look for pseudo classes in each string and put it back together again. E.g. a:hover img becomes ['a:hover', 'img'] becomes ['a', 'img'] ultimately becomes a img.
The text was updated successfully, but these errors were encountered:
From #73 (comment)
@lahmatiy Recommended we hang tight till a better solution becomes available. One, ideally based on AST instead of some hopeful regex juggling.
We might want to consider a partial improvement that'll solve some of the easier things to tackle. For example, we can maintain a white list of pseudo selectors that are valid/important and works with
cheerio
. E.g.:not
.Another partial improvement is to split the selector by spaces, look for pseudo classes in each string and put it back together again. E.g.
a:hover img
becomes['a:hover', 'img']
becomes['a', 'img']
ultimately becomesa img
.The text was updated successfully, but these errors were encountered: