diff options
Diffstat (limited to 'vendor/minifier/src/css/token.rs')
-rw-r--r-- | vendor/minifier/src/css/token.rs | 8 |
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()]; |