Feature: Make `sheet.isBrowser` configurable or export memory only version of `sheet.js`
Would be nice to be able to fallback to "server like" functionality of StyleSheet and store rules in memory instead of a new stylesheet. I can get the CSS rules from the instance using sheet.rules but every insert auto injects the new rule into the style appended by the sheet.inject. Example use case would be pre-rendering markup/css and injecting into an iframe client-side.
related - #38.
will consider ater v3. thanks for the feedback!
can you describe your usecase with more specifics, if you're still interested in this?
use case is using a service worker to generate html/css and then injecting css into iframe(s). in other words, I want to take the css and manually inject where I see fit on the client side.
qq - does window exist inside a service worker?
I ask because glamor does a check on window's existence, and otherwise drops to the memory backed version, so it should already work as you require.
I'm going to close this preemptively, but feel free to reopen if I'm wrong.
@threepointone the primary request is to generate CSS as a string on the client-side. The request originated by the need to inject generated CSS into one or more iframes without applying the rules generated to the parent DOM. Currently I can use cssRules to extract the generated styles but then would need to immediately flush to remove CSS that was injected into a glamor stylesheet unintentionally.
I can make a PR if you'd prefer, just want to see what the consensus is on such a feature.
Ah I see. What's the service worker about then? Reopening this, also related - #268
Do you need just the sheet to do this, or all of glamor?
Just sheet I believe, sorry about the confusion related to service workers. I've worked around the problem since I originally filed the feature in Feb, and was basing my comments off the current implementation rather the original problem.
No need for a PR, if it's just the sheet, I'll do it myself. Should be done and released by the weekend.
I'd like to hear more about your usecase if you don't mind. Why exactly are you building?
Originally was using cxs, which uses glamor's sheet logic. Goal was to render dynamic content previews and injected into iframes. We ran into several issues however w/ media queries and css shorthand conflicts with longhand when trying to cache functional css classes.. but our revised version works pretty well thus far.
I'll rephrase - can you describe the actual product to me? Please and thanks!