mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
fix(html/minifier): Fix removal of comments (#4974)
This commit is contained in:
parent
78ced2d65c
commit
8e63b0bbd5
@ -598,6 +598,20 @@ impl Minifier {
|
||||
}
|
||||
|
||||
impl VisitMut for Minifier {
|
||||
fn visit_mut_document(&mut self, n: &mut Document) {
|
||||
n.visit_mut_children_with(self);
|
||||
|
||||
n.children
|
||||
.retain(|child| !matches!(child, Child::Comment(_)));
|
||||
}
|
||||
|
||||
fn visit_mut_document_fragment(&mut self, n: &mut DocumentFragment) {
|
||||
n.visit_mut_children_with(self);
|
||||
|
||||
n.children
|
||||
.retain(|child| !matches!(child, Child::Comment(_)));
|
||||
}
|
||||
|
||||
fn visit_mut_document_type(&mut self, n: &mut DocumentType) {
|
||||
n.visit_mut_children_with(self);
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
<!--test--><!doctype html><!--test-->
|
||||
<!--test--><html lang="en"><!--test-->
|
||||
<!--test--><head><!--test-->
|
||||
<!--test--><title>Document</title><!--test-->
|
||||
<!--test--></head><!--test-->
|
||||
<!--test--><body><!--test-->
|
||||
<!--test-->
|
||||
<div>test</div>
|
||||
<!--test-->
|
||||
<!--test--></body><!--test-->
|
||||
<!--test--></html><!--test-->
|
||||
<!--test-->
|
@ -0,0 +1,6 @@
|
||||
<!doctype html><html lang=en><title>Document</title><body>
|
||||
|
||||
<div>test</div>
|
||||
|
||||
|
||||
|
@ -13,5 +13,9 @@
|
||||
test
|
||||
</div>
|
||||
</template>
|
||||
<template>
|
||||
<!-- test -->
|
||||
<div>Test</div>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
@ -4,4 +4,8 @@
|
||||
test
|
||||
</div>
|
||||
</template>
|
||||
<template>
|
||||
|
||||
<div>Test</div>
|
||||
</template>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user