4 ms·
Thanks! This is covered at the end of the post, but I can elaborate a bit here. HTM mirrors JSX syntax, which means it requires closing tags for every element.
by mbostock 7y ago
Thanks! This is covered at the end of the post, but I can elaborate a bit here.
HTM mirrors JSX syntax, which means it requires closing tags for every element. We wanted HTML5 syntax instead, which means our parser needs to handle void elements and missing close tags, and a variety of other edge cases (such as “bogus” comments) whose behavior is defined by the HTML5 specification.
Another important feature for us is contextual namespaces. If you have a G element within HTML, it’s an unknown element, but within SVG it’s a group element. HTM (and JSX, HyperScript, and similar approaches) build the DOM from leaves up, so at the time you create the element, you don’t know what the parent is and thus can’t infer the appropriate namespace. That’s fixable by changing what HTM passes to the “pragma”, but it would require changing the signature.
- mhd 7y agoThat's a pretty good selling point. I always was quite disappointed that after years and years of finding more writable alternatives to the verbosity of HTML, we picked up the worst version of it (from a writing-as-a-human perspective). That always bothered me way more than mixing markup and code. HTML5 by comparison ain't that bad and it's the language you'd also be using when writing things manually. So I appreciate the effort. Pairing that with preact might be a good toy project.