Parsing self closing tag produce bad html
See original GitHub issueSelf closing tag is been removed.
Example :
cheerio.load(`<div class="n-content-video n-content-video--youtube">
<iframe src="https://www.youtube.com/?rel=0"/>
</div>`).html()
This produces :
'<html><head></head><body><div class="n-content-video n-content-video--youtube"> <iframe src="https://www.youtube.com/?rel=0"> </div></iframe></div></body></html>'
As you can see closing slash from iframe has disappeared producing bad html syntax
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Are (non-void) self-closing tags valid in HTML5?
The slash at the end of the start tag is allowed, but has no meaning. It is just syntactic sugar for people (and...
Read more >Template parser produces wrong locations for HTML self ...
Template parser from @angular/compiler package produces wrong locations for HTML self-closing tags. Here the initial simple template: <input ...
Read more >How to respect non-self-closing br tags when apex parsing ...
This appears to be because this string is treated as "xhtml+xml" or maybe just "xml" content type, despite the class name being Dom.Document...
Read more >T134423 Deprecate nonstandard behavior of self-closed ...
HTML5 just says that void elements can have any end tag and must then be self-closed or implicitly closed immediaterly without parsing any...
Read more >Self Closing Tags in HTML (With Examples) - Tutorials Tonight
A self closing tags in HTML are the type of HTML tags that need not to be closed manually by its closing tag,...
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 FreeTop 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
Top GitHub Comments
When I put code (from above) into Chrome browser I got:
so browser actually closes
iframe
before it’s parent elementdiv
maybe you should decode content first, so you can avoid this “repairing” functionality.
result:
The problem comes from transforming from xml to html
it produces
Shouldn’t be the output text the same as the input ?