4 ms·
I'm still laughing about the fact that JSX renders to XHTML, not the HTML5 that browsers actually use. 99% of the time they're the same and parsing occurs as ex
by ttfkam 2y ago
I'm still laughing about the fact that JSX renders to XHTML, not the HTML5 that browsers actually use. 99% of the time they're the same and parsing occurs as expected. That last 1%, things get weird quick.
- recursive 2y agoJsx doesn't "render to xhtml". Its syntax is similar to XML, but not the same. It's similar to HTML, but not the same. It's similar to XHTML, but not the same. In most react apps it renders to function calls like createElement or _jsx. The reconcile will turn these into DOM objects without any markup representation at all.
- ttfkam 2y agoDo you have to close all of your tags? Yes. Is the markup based on HTML with XML rules like closing tags? Yes. Do you even have to close the tags of your custom components? Yes. When generating your createElement sequence from JSX, does it create or close tags in a different order/hierarchy than what you specified in the JSX? No. Does it emit markup or element creation calls that match the parsing behavior of HTML5? No. Walks like an XHTML duck. Talks like an XHTML duck. It's an XHTML duck despite the JS interop and the lack of DTD preamble.
- recursive 2y agoDoes not have namespaces (in react), CDATA, schemas, and more. And none of this is "rendering".
- deleted 2y ago[deleted]
- ttfkam 2y agoThe "reconcile" (my God do geeks love making what they do sound fancier than it is) does not match the HTML5 parser "reconciliation" spec. The DOM element API "emissions" match the order triggered by the markup parsers. Y'all are tiresome sometimes.
- recursive 2y agoI legitimately don't understand what you're getting at.
- deleted 2y ago[deleted]
- eyelidlessness 2y agoWhere did you get this idea? JSX doesn’t specify what markup it renders to, or even that it renders to any markup at all. The syntax most closely resembles XML (and therefore XHTML), in that it requires closing tags (which might be satisfied by self-closing with />). But this is an authoring constraint, it has no bearing at all on output.
- ttfkam 2y agoSo… you can use other markups seamlessly like SVG and MathML… just like XHTML. Walk like a duck, talk like a duck.
- eyelidlessness 2y agoHuh? I didn’t say anything about what markup languages you can use.
- recursive 2y agoNot exactly seamless. You have to change some of the attribute casing in svg.