view-scoped CSS via JSS
See original GitHub issueNow that view closures can return {render: ...}
objects, we should evaluate offering the option of returning {css: ...}
as part of the mix, possibly accepting a JSS-style [1] stylesheet definition. Each vm is already tagged with a globally unique sequential .id
, so the styles can be prefixed to isolate/prevent leakage. Another option is to prefix the defs with the function.name
of the the view closure. This means all views created using the same closure would by styled uniformly. In both cases the view’s root nodes would need the generated prefixes auto-appended to their className.
JSS pairs well with vdom/hyperscript style libs since it’s js-assembled CSS, much like like js-assembled DOM.
This would make for a good isolated and high-ROI project if anyone wants to take charge, since it wouldn’t require intricate familiarity with domvm’s internals. 98% of it can live decoupled as an addon.
Issue Analytics
- State:
- Created 7 years ago
- Comments:44 (17 by maintainers)
Top GitHub Comments
In my opinion, the ‘C’ in CSS stands for a vulgar term referring to unwilling intercourse with a group of assailants. But we are stuck with it because our industry can’t, as a group, design it’s way out of a paper bag.
They almost partly fixed this with the introduction of
<style scoped>
and then someone realized that this would make too many developers’ lives easier and unceremoniously kiboshed it, throwing the baby out with the bathwater instead of recognizing that the suggestion reveals a gaping problem with the current state of the art (art is used loosely here).As a whole, we still haven’t collectively recognized that the “specificity” rules aren’t rules, but more guidelines for the partly-insane and savants among us. Add to this that the cascade refers to seepage of unintended side-effects that make even the most well meaning effort devolve into gibberish with 6 weeks of having been written.
So we continue to pursue the heights of madness, ever courting danger on the brink of despair, in an everlasting effort, doomed to ultimate failure, to write sane, maintainable styles to control the visuals of an application, using tools designed to produce documents. BECAUSE THERE’S NOTHING ELSE.
So yes, we should wrestle with this until we can do something better, or realize that doing the same thing using a different syntax is folly.
(rant over)
hooks patch landed: https://github.com/leeoniya/domvm/commit/b2ccddbe7a2195d5ce1fdfca9618b81f6244a05a