summaryrefslogtreecommitdiffstats
path: root/vendor/minifier/src/css/token.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/minifier/src/css/token.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/minifier/src/css/token.rs')
-rw-r--r--vendor/minifier/src/css/token.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/vendor/minifier/src/css/token.rs b/vendor/minifier/src/css/token.rs
index 58e416fcd..467bed0fa 100644
--- a/vendor/minifier/src/css/token.rs
+++ b/vendor/minifier/src/css/token.rs
@@ -427,7 +427,7 @@ fn fill_other<'a>(
}
#[allow(clippy::comparison_chain)]
-pub(super) fn tokenize<'a>(source: &'a str) -> Result<Tokens<'a>, &'static str> {
+pub(super) fn tokenize(source: &str) -> Result<Tokens<'_>, &'static str> {
let mut v = Vec::with_capacity(1000);
let mut iterator = source.char_indices().peekable();
let mut start = 0;
@@ -579,6 +579,7 @@ fn clean_tokens(mut v: Vec<Token<'_>>) -> Vec<Token<'_>> {
// Index of the previous retained token, if there is one.
let mut ip: Option<usize> = None;
let mut is_in_calc = false;
+ let mut is_in_container = false;
let mut paren = 0;
// A vector of bools indicating which elements are to be retained.
let mut b = Vec::with_capacity(v.len());
@@ -594,6 +595,9 @@ fn clean_tokens(mut v: Vec<Token<'_>>) -> Vec<Token<'_>> {
paren += 1;
}
}
+ if v[i] == Token::SelectorElement(SelectorElement::Media("container")) {
+ is_in_container = true;
+ }
let mut retain = true;
if v[i].is_useless() {
@@ -609,6 +613,8 @@ fn clean_tokens(mut v: Vec<Token<'_>>) -> Vec<Token<'_>> {
// retain the space after "and", "or" or "not"
} else if is_in_calc && v[ip.unwrap()].is_useless() {
retain = false;
+ } else if is_in_container && matches!(v[ip.unwrap()], Token::Other(_)) {
+ // retain spaces between keywords in container queryes
} else if !is_in_calc
&& ((ip.is_some() && {
let prev = &v[ip.unwrap()];