String styles: please make it easy
See original GitHub issue10.0.0-beta.2 notes say:
We removed support for string styles in favor of setting style properties only with objects. This aligns our behavior with various other virtual-dom based libraries out there ✔️ Nonetheless we are aware that this might be a controversial change. If you have a lot of string styles or want to continue using them, you can use preact-string-styles to patch this behavior back into Preact X. If you don’t agree this change, please let us know!
Let it be known: I’d much prefer to allow string styles. Indeed, the lighter-touch approach that keeps Preact JSX markup closer to actual HTML was one of my motivations for choosing it. I’d also be OK with an NPM package that delivers the functionality of preact-string-styles, whereas currently it’s a gist.
On the plus side, I’d also like to report that string styles still seem to be working fine for me in this beta, at least when rendering to strings via preact-render-to-string
. (In my application, that’s all I need – perhaps the lack of support is in render()
?)
In case you’re curious about my application: I’m using JSX as a way to write beautiful code that generates SVG. (Here’s a simple example.) Thus, I’d like the markup part to look as much like actual SVG as possible. But I realize this isn’t the standard application of Preact, so you might want to relegate this feature to a package.
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (13 by maintainers)
Ok, so after re-reading the thread and everyone’s opinion I’ve come to the conclusion that we should bring string styles back. My reasoning is that we’d break a lot of existing preact apps and we shouldn’t do such change so short before a final X release.
String styles are part of the DOM interface after all and we’ve profited from them in the past back when we lacked support for CSS variables in preact. On top of that having string styles is a lower barrier to entry for beginners as they can just copy & paste their existing html code into jsx and have it work out of the box.
I’ve made #1744 accordingly which brings back string styles.
I’m wondering if we should bring them back mainly for the reason that we advertise as being “closer to the metal” and string styles fit into that description.