css-inline icon indicating copy to clipboard operation
css-inline copied to clipboard

Logically invalid HTML is messed up

Open adrian-zon opened this issue 10 months ago • 3 comments

Input:

<!DOCTYPE html>
<html>
  <head>
    <title>TITLE</title></head>
  <body>
    <table class=wrapper>
      <div class="parent">
        <table class="child"></table>
      </div>
    </table>
  </body>
</html>

Output:

<!DOCTYPE html><html><head>
    <title>TITLE</title></head>
  <body>
    <div class="parent">
        </div><table class="wrapper">
      </table><table class="child"></table>
      
    
  
</body></html>

adrian-zon avatar Mar 14 '25 07:03 adrian-zon

It appears that missing quotes make html5ever parse it this way, or maybe this implementation can handle such cases, not 100% sure yet.

Stranger6667 avatar Mar 14 '25 08:03 Stranger6667

Oh sorry, it's not about the quotes, it's about putting a div directly in a table.

adrian-zon avatar Mar 14 '25 08:03 adrian-zon

Right, I see it now! div can't be used in table as per the HTML spec and I see that e.g. chromium does a similar thing - https://jsfiddle.net/ELzs3/1/ (found that on SO) where div is ejected outside of table. It may work with quirks mode, but I need to try it

Stranger6667 avatar Mar 14 '25 08:03 Stranger6667