Fix spaces not being added between unquoted attributes when requested
This commit is contained in:
parent
c8973d4eac
commit
ece1f84fc4
|
@ -3,3 +3,4 @@
|
||||||
## 0.6.9
|
## 0.6.9
|
||||||
|
|
||||||
- Intrepret `type=module` on `<script>` tags as a JavaScript MIME eligible for its contents to be minified as JavaScript (previously it would not be and so its contents would be considered data and never minified as JavaScript).
|
- Intrepret `type=module` on `<script>` tags as a JavaScript MIME eligible for its contents to be minified as JavaScript (previously it would not be and so its contents would be considered data and never minified as JavaScript).
|
||||||
|
- Fix issue where spaces are not added between unquoted attributes even when `cfg.keep_spaces_between_attributes` is `true`.
|
||||||
|
|
|
@ -306,7 +306,7 @@ pub fn minify_attr(
|
||||||
if should_trim {
|
if should_trim {
|
||||||
right_trim(&mut value_raw);
|
right_trim(&mut value_raw);
|
||||||
left_trim(&mut value_raw);
|
left_trim(&mut value_raw);
|
||||||
}
|
};
|
||||||
if should_collapse {
|
if should_collapse {
|
||||||
collapse_whitespace(&mut value_raw);
|
collapse_whitespace(&mut value_raw);
|
||||||
};
|
};
|
||||||
|
@ -325,7 +325,7 @@ pub fn minify_attr(
|
||||||
&value_raw_wrapped,
|
&value_raw_wrapped,
|
||||||
&MINIFY_CSS_TRANSFORM_OPTIONS.clone(),
|
&MINIFY_CSS_TRANSFORM_OPTIONS.clone(),
|
||||||
);
|
);
|
||||||
// If input was invalid, wrapper syntax may not exist anymore.
|
// TODO If input was invalid, wrapper syntax may not exist anymore.
|
||||||
if value_raw_wrapped_min.starts_with(b"x{") {
|
if value_raw_wrapped_min.starts_with(b"x{") {
|
||||||
value_raw_wrapped_min.drain(0..2);
|
value_raw_wrapped_min.drain(0..2);
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,8 +75,9 @@ pub fn minify_element(
|
||||||
}
|
}
|
||||||
for (i, (name, value)) in unquoted.iter().enumerate() {
|
for (i, (name, value)) in unquoted.iter().enumerate() {
|
||||||
// Write a space between unquoted attributes,
|
// Write a space between unquoted attributes,
|
||||||
// and after the tag name if it wasn't written already during `quoted` processing.
|
// or after the tag name if it wasn't written already during `quoted` processing,
|
||||||
if i > 0 || (i == 0 && quoted.len() == 0) {
|
// or if forced by Cfg.
|
||||||
|
if i > 0 || (i == 0 && quoted.len() == 0) || cfg.keep_spaces_between_attributes {
|
||||||
out.push(b' ');
|
out.push(b' ');
|
||||||
};
|
};
|
||||||
out.extend_from_slice(&name);
|
out.extend_from_slice(&name);
|
||||||
|
|
|
@ -128,6 +128,12 @@ fn test_viewport_attr_minification() {
|
||||||
b"<meta name=viewport content='width=device-width, initial-scale=1'>",
|
b"<meta name=viewport content='width=device-width, initial-scale=1'>",
|
||||||
b"<meta content=width=device-width,initial-scale=1 name=viewport>",
|
b"<meta content=width=device-width,initial-scale=1 name=viewport>",
|
||||||
);
|
);
|
||||||
|
let spec_compliant_cfg = Cfg::spec_compliant();
|
||||||
|
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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "js-esbuild")]
|
#[cfg(feature = "js-esbuild")]
|
||||||
|
|
Loading…
Reference in New Issue