3 ms·
lit-html also returns a data structure - strings and values. You can interpret the strings however you want. JSX actually doesn't return a data structure. It's
by spankalee 6y ago
lit-html also returns a data structure - strings and values. You can interpret the strings however you want.
JSX actually doesn't return a data structure. It's syntax only and some transforms do things quite different from what React.createElement() does. And this is part of the problem with it and why it can't really be standardized - there's no semantics to standardize.
lit-html as an render implementation does indeed target only the DOM, it's not trying to target non-web platforms.
- eyelidlessness 6y agoSorry, I misstated my point. JSX is itself a data structure, not interpolated strings and values. That makes it closer to hyperscript. But it doesn’t necessarily return anything or have a runtime value at all. The problems you cite are exactly what I meant to say are its strengths. Because it’s entirely undefined syntax that only corresponds to data, it can be used as a general purpose macro for anything from React.createElement to defining a web component to defining an output for a CLI to defining a test or an API endpoint or anything at all. It’s a general purpose DSL, and the fact that it looks like HTML/XML is just convenient for its most common usage.
- deleted 6y ago[deleted]
- spankalee 6y agoJSX really isn't a data structure, is just syntax. Sometimes it's compiled to statements, like with some idom transforms.
- eyelidlessness 6y agoJSX is an expression with structural semantics. It doesn’t have to be compiled to a data structure but at the AST level it definitely is, which is the whole point.