Skip to content

Commit ef41ee8

Browse files
committed
test(html): assert the whole printed body a data block trims to
The mode and foreign-content cases matched a substring, so anything else the printer wrote past it went unchecked. They read the body back the way the cases around them do. The changeset entry is one sentence again.
1 parent 09ebfa2 commit ef41ee8

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎.changeset/010-css-html-minify.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": patch
33
---
44

5-
Minify more HTML and CSS shorthands, trim the body of a <script> holding a data block, and cut two costs off printing.
5+
Minify more HTML and CSS shorthands, trim data-block scripts, cut print costs.

‎test/HtmlSyntax.unittest.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4207,15 +4207,17 @@ describe("SourceProcessor — JSON <script> bodies", () => {
42074207
'<script type="text/x-template"> x </script>',
42084208
{ mode: "minify", collapseWhitespace }
42094209
).code;
4210-
expect(out).toContain(">x<");
4210+
expect(out.slice(out.indexOf(">") + 1, out.lastIndexOf("</script>"))).toBe(
4211+
"x"
4212+
);
42114213
});
42124214

42134215
it("trims a data block in foreign content too", () => {
42144216
const out = new SourceProcessor().process(
42154217
'<svg><script type="text/x-template"> x </script></svg>',
42164218
{ mode: "minify", collapseWhitespace: "all" }
42174219
).code;
4218-
expect(out).toContain(">x<");
4220+
expect(out).toBe("<svg><script type=text/x-template>x</script></svg>");
42194221
});
42204222

42214223
it("leaves a data block alone where whitespace is kept", () => {

0 commit comments

Comments
 (0)