🙋 HTML parsing too strict?
See original GitHub issue🙋 Feature Request
🎛 Configuration (.babelrc, package.json, cli command)
{
"your": { "config": "just using the default out of the box..." }
}
🤔 Expected Behavior
This is the html source and what I was expecting to be output.
<div id="visual">
<div id="jet-icon" />
<div id="runway-icon" />
</div>
😯 Current Behavior
This is the output which is nested differently by the browser.
<div id="visual">
<div id="jet-icon">
<div id="runway-icon">
</div>
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why was strict parsing not chosen for HTML?
XHTML in principle imposes strict (XML) parsing rules, so that an XHTML document served with an XML content type will be displayed only...
Read more >Strict HTML parsing in JavaScript - Stack Overflow
Use the DOMParser to check a document in two steps: Validate whether the document is XML-conforming, by parsing it as XML.
Read more >Should HTML Parsing in Browsers Be Standardized? - Medium
They decided that the HTML parser their browser implemented would not strictly parse markup. Strictly parse? So what does that mean?
Read more >8.2 Parsing HTML documents — HTML5 - W3C
However, few (if any) web browsers ever implemented true SGML parsing for HTML documents; the only user agents to strictly handle HTML as...
Read more >load coco dataset
It's hard to know for sure what's gone wrong, but here are some ... Python provides the ElementTree API that can be used...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

In situations like this, it’s best to use
curlrather than looking at the browser’s DOM:So, parcel doesn’t actually transform the HTML at all – it just passes the HTML straight to the browser.
I experimented with setting different doctypes (html4, xhtml1.0, xhtml1.1) but it seemed to make no difference: chrome simply doesn’t support self-closing div tags.
It’s tempting to say that parcel should just fix the problem (by turning
<div />into<div></div>automatically), but that’s probably a bad idea. There are cases where a user wants to generate invalid HTML, e.g. unit testing.Vue.js deals with similar issues. If you try to write
<table><my-component></table>, the browser automatically inserts<table><tbody><my-component></tbody></table>, which screws up Vue’s virtual rendering.We should probably follow Vue’s lead and simply leave the HTML untouched.
edit: fixed formatting.
@shawwn I’m explaining that I did
curland still do see parcel serving the<div>instead of the<div/>.If you’re not seeing removed slashes it might be because you don’t have a
<link rel="stylesheet" type="text/css" href="./index.css" />in your<head>which I only now discovered is required to get parcel to remove the slashes.