capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.08k stars 185 forks source link

Relaxed parsing on broken html #1460

Open masylum opened 3 weeks ago

masylum commented 3 weeks ago

Describe the bug The behavior of the DomParser is suboptimal when dealing with broken html. The browser implementation handles it gracefully, but happy-dom seems to choke.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://danluu.com/dunning-kruger/ and copy the html. It's broken with missing body and closing tags.
  2. Use the browser to do DomParser#parseFromString(html, 'text/html')
  3. Do the same with happy-dom
  4. See that the browser one works, but happy-dom does not

Expected behavior It would be great to handle broken html, since the internet is full of it.

Thanks in advance! Great library and gigantic effort.