question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect DOM parsing with self-closing tags

See original GitHub issue

Hi! 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
capricorn86commented, Aug 16, 2021

Thanks for reporting @yankouskia! 🙂

I will look into fixing it as soon as possible.

0reactions
capricorn86commented, Dec 21, 2021

I will close this for now as I can’t reproduce it. Just re-open it if you still have the bug.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found