Re: [csswg-drafts] [css-env-1] - Pushing data from CSS? (#4911)

> If there were a way to push data into JavaScript land, perhaps in the form of an event or signal of some sort, then a script could handle the setting of a custom rule on a set of elements without having to watch the DOM and stylesheets for a custom property that is intended to be "JS enhanced".

Yes, this is planned for a future Houdini spec: letting JS process a custom property to produce a "computed value" or "used value", and/or letting JS register "property listeners" on elements that get called when a property's value changes.

> Another use-case could be pushing data when media queries are activated; then JS could perhaps make further responsive enhancements (as responsive design is currently the prime motivator for using media queries).

This can already be done! You can evaluate MQs directly in JS, and register a listener for when they change: <https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener>

> Some other ideas: calc could be supplemented with other functions whose implementation is in JS - however, this would be hidden to the user of the function, preserving the declarative, decorative semantics of CSS. Any function could be defined; e.g., string manipulation functions, numeric-valued functions, such as, say, grabbing the width of another element for use in a value (e.g. height: calc(width(#myDiv) + 2em)).

This is another planned Houdini spec: Houdini Custom Functions. ^_^

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4911#issuecomment-608595321 using your GitHub account

Received on Friday, 3 April 2020 18:32:47 UTC