Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why/how do you grep selectors? Seems overly optimistic to be able to guess the particular rule pattern that is applying a style. Browser tools are much more reliable.
 help



Let's say you're thrown into a website you've never worked on before and asked to fix a styling problem. You can look in the browser tools, but the website will only be running the compiled production version, and if the team knows what they're doing there won't be source maps available.

So you've now found selectors in DevTools that you think are causing the problem, and you want to find them in the source code. In the case of many projects, that means searching through hundreds of small CSS files.

That's why you grep selectors, and where the pain comes. You have to start with the most specific rules that you found in DevTools, then start deleting parts from them until you find a non-nested rule that's in the source, yet still specific enough that you haven't got hundreds of matches to go through.

It would be great if something like ast-grep could take a CSS rule copied from DevTools and search for nested CSS that would compile to match it.


> if the team knows what they're doing there won't be source maps available

What's so bad about source maps?


If this is the only option, I would suggest that means the team doesn't know what they are doing.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: