demo · v143
Parser vs JS
The reason for the change: the HTML parser accepts characters that createElement rejected. We parse an HTML string and then try to reconstruct the same tree programmatically — and see whether the two paths agree.
HTML snippet
1. innerHTML (parser)
—
2. createElement/setAttribute (JS)
—
Run a sample to see whether your browser's two paths agree.
the call
// Both should produce the same tree. Pre-v143, the parser accepted
// non-ASCII tag names but createElement threw — so this round-trip failed.
const html = "<café-card>hi</café-card>";
// Path 1: parser
host.innerHTML = html;
const fromParser = host.firstChild;
// Path 2: JavaScript
const fromJs = document.createElement("café-card");
fromJs.textContent = "hi";
// v143: fromJs.tagName === fromParser.tagName ✅
why this angle
The original createElement demo shows what works. This one shows why it had to change — the HTML parser always accepted these characters, so any tool that round-trips HTML (templating, serializers, framework hydration) had a mismatch baked in. v143 closes the gap.