Do not remove empty alt tag
This commit is contained in:
parent
6e2f2465a4
commit
e93188f9b7
|
@ -1,5 +1,9 @@
|
|||
# minify-html changelog
|
||||
|
||||
## 0.7.1
|
||||
|
||||
- Do not remove `alt` tag when empty.
|
||||
|
||||
## 0.7.0
|
||||
|
||||
- Fix Node.js library not including `cli.js`.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"@types/node": "^16.4.13",
|
||||
"@wzlin/html-data": "^2021081005.0.0",
|
||||
"@wzlin/html-data": "^2021121401.0.0",
|
||||
"ts-node": "^10.2.0",
|
||||
"typescript": "^4.3.5"
|
||||
}
|
||||
|
|
|
@ -460,9 +460,15 @@ fn test_processing_instructions() {
|
|||
#[test]
|
||||
fn test_js_minification() {
|
||||
eval_with_js_min(b"<script>let a = 1;</script>", b"<script>let a=1;</script>");
|
||||
eval_with_js_min(b"<script type=text/javascript>let a = 1;</script>", b"<script>let a=1;</script>");
|
||||
eval_with_js_min(
|
||||
b"<script type=text/javascript>let a = 1;</script>",
|
||||
b"<script>let a=1;</script>",
|
||||
);
|
||||
// `export` statements are not allowed inline.
|
||||
eval_with_js_min(b"<script type=module>let a = 1; export a;</script>", b"<script type=module></script>");
|
||||
eval_with_js_min(
|
||||
b"<script type=module>let a = 1; export a;</script>",
|
||||
b"<script type=module></script>",
|
||||
);
|
||||
eval_with_js_min(
|
||||
br#"
|
||||
<script>let a = 1;</script>
|
||||
|
|
|
@ -122,6 +122,16 @@ fn test_attr_whatwg_unquoted_value_minification() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_alt_attr_minification() {
|
||||
eval(br#"<img alt=" ">"#, br#"<img alt=" ">"#);
|
||||
eval(br#"<img alt=" ">"#, br#"<img alt=" ">"#);
|
||||
eval(br#"<img alt="">"#, br#"<img alt>"#);
|
||||
eval(br#"<img alt=''>"#, br#"<img alt>"#);
|
||||
eval(br#"<img alt>"#, br#"<img alt>"#);
|
||||
eval(br#"<x-any-tag alt>"#, br#"<x-any-tag alt>"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_viewport_attr_minification() {
|
||||
eval(
|
||||
|
@ -132,7 +142,7 @@ fn test_viewport_attr_minification() {
|
|||
eval_with_cfg(
|
||||
b"<meta name=viewport content='width=device-width, initial-scale=1'>",
|
||||
br#"<meta content="width=device-width,initial-scale=1" name=viewport>"#,
|
||||
&spec_compliant_cfg
|
||||
&spec_compliant_cfg,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ pub fn process_tag(
|
|||
.is_none();
|
||||
if script_tag_type_is_js {
|
||||
if &proc[value.unwrap()] != b"module" {
|
||||
erase_attr = true;
|
||||
erase_attr = true;
|
||||
};
|
||||
} else {
|
||||
// Tag does not contain JS, don't minify JS.
|
||||
|
|
Loading…
Reference in New Issue