Incorrect DOM parsing with self-closing tags
See original GitHub issueHi! I am trying to use the package for the custom parsing of DOM with custom component, but getting incorrect response for the markup with self-closing tags. Example:
const { Window } = require('happy-dom');
const window = new Window();
const document = window.document;
document.body.innerHTML = `
<html>
<head>
<custom-attributes>
<custom-accordion />
<custom-accordion-element />
<custom-accordion-text />
</custom-attributes>
</head>
<body>
</body>
</html>
`;
console.log(window.document.body.innerHTML);
Expected output:
<html>
<head>
<custom-attributes>
<custom-accordion></custom-accordion>
<custom-accordion-element></custom-accordion-element>
<custom-accordion-text></custom-accordion-text>
</custom-attributes>
</head>
<body>
</body>
</html>
Actual output:
<html>
<head>
<custom-attributes>
<custom-accordion>
<custom-accordion-element>
<custom-accordion-text>
</custom-accordion-text>
</custom-accordion-element>
<body>
</body>
</custom-accordion></custom-attributes></head></html>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Issue in reading self closing tag in javascript - Stack Overflow
Self -terminated tag syntax means nothing to the HTML parser. It just ignores the / in the tag and sees it as an...
Read more >Custom Self Closing Tags treat following text as children data
Steps to reproduce: Run parser with a replace option using this text: This text has a self closing tag <Example /> for you...
Read more >How to respect non-self-closing br tags when apex parsing ...
Dom.Document, despite its namespace, is an XML parser. It is not meant to handle <br> , because XML doesn't allow it.
Read more >Plump
Plump is a parser for HTML/XML like documents, focusing on being lenient towards invalid markup. It can handle things like invalid attributes, bad...
Read more >13.2 Parsing HTML documents - HTML Standard - WhatWG
The rules for parsing XML documents into DOM trees are covered by the next ... incorrectly-closed-comment ... (Self-closing tags don't exist in HTML.) ......
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
Thanks for reporting @yankouskia! 🙂
I will look into fixing it as soon as possible.
I will close this for now as I can’t reproduce it. Just re-open it if you still have the bug.