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

Nice. But from the description, it apparently doesn't work if you construct class names by string manipulation (like "item_" + (selected ? "selected" : "")). Maybe you shouldn't do that anyway, though.


Even worse, I've sometimes done things like

  $(...).addClass("bg" + getSomeClassIdentifier(obj))
Linking some string hanging off some runtime object to its CSS class usage quickly runs into halting problem issues.

There are certainly some arguments to keeping class names as opaque magic strings, but given certain levels of dynamic complexity and the lack of tools like CSS class inheritance, naming policy is sometimes far cleaner and more manageable.

Also, there is a minor concern about false positives. If you have a class called "name" or something generic like that, the odds of that string appearing in non-CSS usage your source code is fairly high.


Ah, thanks for noticing. Actually, with the current implementation, it would still work I believe




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: