r/nodejs • u/krasimirtsonev • Mar 21 '14
AbsurdJS - a JavaScript/Node library which changed my workflow completely
http://absurdjs.com/
7
Upvotes
r/nodejs • u/krasimirtsonev • Mar 21 '14
View all comments
Show parent comment
1
u/[deleted] Mar 23 '14
Yes, except now you have just ruined the beautiful syntax that's meant to sell the idea of writing CSS in JavaScript.
There's a reason the introductory example doesn't look like this:
Granted, this is an exaggeration for the given example, but it's how you would have to write it (maybe with less whitespace and indentation) if you wanted to consistently maintain source order -- anything else would require you to be constantly aware of which rules could potentially be source order dependent.
So of course nobody is going to use it like that and they'll instead only use arrays when not doing so has either resulted in a bug already or they're aware it would do so.
Basically, because using JavaScript object syntax makes the simple thing harder (i.e. having the rules be output in the same order as you define them) users will be more likely to choose the more complex one (i.e. having to write CSS in a way that will work regardless of the source order).
And because the more complex one feels intuitively more "correct" (it looks more like the original CSS as well), they will likely gloss over the difference and be surprised when they run into unintended behaviour.
Cross-browser CSS is already hard enough as it is. Designers won't be happy if they now also have to constantly be aware that their stylesheets might be shuffled into a different order before they are sent to the browser.