Skip to content

Commit 73b77bd

Browse files
alexander-akaitclaude
authored andcommitted
test(html): cover the comment branch of the implied-tag guard
A comment leaves the body altogether — the modes put it in the element above — so it is its own case, not the head element's.
1 parent 1274b1d commit 73b77bd

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎test/HtmlSyntax.unittest.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,6 +4632,18 @@ describe("SourceProcessor — removeImpliedTags", () => {
46324632
).toBe("<body><style>a{color:red}</style>");
46334633
});
46344634

4635+
it("materializes an implied tag whose content opens with a comment", () => {
4636+
// A comment there goes further out than a head element does: the modes put
4637+
// it in the element above the body, so it leaves the body altogether.
4638+
expect(
4639+
new SourceProcessor().process("<tr><!--c--><p>x", {
4640+
mode: "minify",
4641+
removeImpliedTags: true,
4642+
preserveComments: [/c/]
4643+
}).code
4644+
).toBe("<body><!--c--><p>x");
4645+
});
4646+
46354647
it("keeps a <html> that carries an attribute", () => {
46364648
expect(
46374649
new SourceProcessor().process("<html lang=en><body>x", { mode: "minify" })

0 commit comments

Comments
 (0)