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.
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.
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.