News for hackers. Stuff that matters.
Re:Fix CSS by writing it in JavaScript by dugmartin on Tuesday November 25, 2014 @11:58AM (#8658488)
As spion says with web components on the horizon, and with current frameworks like React, having classnames live in the global namespace makes creating reusable components that don't clash with other components impossible.

I have a hunch some consensus will evolve that will use Java/AS3 namespace prefixes to enable sharing, so instead of .button you'll have something like .com-github-dougmartin-button.

Re:Fix CSS by writing it in JavaScript by talmand on Tuesday November 25, 2014 @12:06PM (#8658531)
Or even better, namespace the classes with nesting; which you can today with or without a prepocessor. Such verbose classnames is not necessary.
Re:Fix CSS by writing it in JavaScript by spion on Tuesday November 25, 2014 @01:30PM (#8658931)
Yes, namespacing is the best currently available option. Unfortunately its only an approximation of lexical scope, as the example in the presentation shows (the one with the two red buttons).

True, this is not something that happens often, and we can mostly get away with namespaces. But that's not the point. The point is that lexical scope is a tried and proven (by years of research, in multiple languages) solution to this problem which doesn't have any of these quirks. And JS has lexical scope.

Re:Fix CSS by writing it in JavaScript by talmand on Tuesday November 25, 2014 @02:26PM (#8659226)
The example with the two buttons is inherently flawed and is a bad example. It specifically creates an easily preventable problem in an effort to show a solution to that problem.

There is nothing that this library can do that I cannot hand-code in CSS myself. Because it has to generate the CSS that the browser expects to get, which is not hard to do.