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

genuinely curious, how does option 5 prevent specificity bombs?


It’s a fair question. Almost anything can be a weapon if you try hard enough. “Prevent” is perhaps too strong a verb. I’d settle for discourage or maybe even just contextualize. I get the impression that by explicitly declaring each nesting context with “@nest”, the effort required to type those extra characters might center the meaning more around code organization, maybe? If nothing else, it helps the eye track better in deeper trees.

In my experience, when I’ve committed this sin or watched others do so, it’s often because some styles that have already been written need to be updated. Writing CSS is really easy. Nesting makes it even easier. The thing I and I think most people struggle with is organizing it. I think nested styles encourage people to go out in search of a defined scope to ammend moreso than it does to encourage them to write a new one (or selector). It’s easy to see a class you’d need, skip a couple levels down the tree and then get excited when you add just that one element or class you think you need and style accordingly… Only to find out later that you created a difficult to debug style bug that pervades the whole site. My hope is that it would encourage people to think twice before going beyond that second or third level and maybe encourage them to create a new style block instead. I’m also not terribly concerned length or effort these days because of tab completion.




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

Search: