4 ms·
Another ugly historical snapshot, but JS in CSS instead: https://jezenthomas.com/you-think-css-in-js-is-bad/ https://jezenthomas.com/you-think-css-in-js-is-bad
by yakshaving_jgt 5y ago
Another ugly historical snapshot, but JS in CSS instead:
https://jezenthomas.com/you-think-css-in-js-is-bad/ https://jezenthomas.com/you-think-css-in-js-is-bad/
- err4nt 5y agoToday we have CSS custom properties which do similar things: - Authors can define custom properties as long as they start with a double-dash, like --demo - Authors can leave these values empty, or put any code that doesn't break CSS's syntax inside. This can be CSS values, it can be JSON, it can be other languages, even some JavaScript could be stored in CSS to be read later - Using JavaScript you can read the values of CSS custom properties, and set them So it's possible with a tiny bit of JS to re-create what the old IE expression() function used to do in any modern browser in a fully standards-compliant way
- mushyhammer 5y ago> So it's possible with a tiny bit of JS Not really. expression() was evaluated by just moving the mouse around, which is what allowed attaching stuff to your cursor with "just some CSS" https://web.archive.org/web/20120420154658/http://msdn.microsoft.com/en-us/library/ms537634(v=VS.85).aspx https://web.archive.org/web/20120420154658/http://msdn.micro... To do what expression() could do you need several event listeners at least which, I mean, of course you can still do it, but it's really unrelated to CSS Properties and just JavaScript at this point.
- err4nt 5y agoThis is actually part of the design of CSS custom properties. It's not an abuse, but part of how they've been designed to be used. You can trigger updates from your own code programmatically, as well as any event listeners (built-in or custom) or from Observers the browser may have (e.g. Resize Observer, Intersection Observer, Mutation Observer) or any other ways you want to update them!
- tomxor 5y agoIE also had a custom image filtering scripting language embedded in CSS that was pretty dangerous, you could easily hang someone's whole computer if you weren't careful. A common hack to find was adding png transparency which IE infamously lacked, at great computational cost to the user (this was at a time where the lack of other CSS features made PNG transparency quite necessary for building fancy UIs). It's worth pointing out that many of the old ugly things were IE specific including the feature referenced by the parent comment... it was a time when "standard" had little weight, although some of the good ideas like box-sizing were adopted by W3C.