support special fn clamp

This commit is contained in:
Connor Skees 2021-07-30 05:57:13 -04:00
parent eadd7c5041
commit c6cb7c1d68
3 changed files with 24 additions and 0 deletions

View File

@ -278,6 +278,9 @@ impl<'a, 'b> Parser<'a, 'b> {
.to_css_string(self.options.is_compressed())?, .to_css_string(self.options.is_compressed())?,
), ),
}, },
"clamp" if lower == "clamp" => {
self.parse_calc_args(&mut s)?;
}
_ => s.push_str( _ => s.push_str(
&self &self
.parse_call_args()? .parse_call_args()?

View File

@ -4,4 +4,5 @@ pub(crate) fn is_special_function(s: &str) -> bool {
|| s.starts_with("env(") || s.starts_with("env(")
|| s.starts_with("min(") || s.starts_with("min(")
|| s.starts_with("max(") || s.starts_with("max(")
|| s.starts_with("clamp(")
} }

View File

@ -234,3 +234,23 @@ error!(
progid_nothing_after, progid_nothing_after,
"a { color: progid:", "Error: expected \"(\"." "a { color: progid:", "Error: expected \"(\"."
); );
test!(
clamp_empty_args,
"a {\n color: clamp();\n}\n",
"a {\n color: clamp();\n}\n"
);
test!(
clamp_parens_in_args,
"a {\n color: clamp((()));\n}\n",
"a {\n color: clamp((()));\n}\n"
);
test!(
clamp_single_arg,
"a {\n color: clamp(1);\n}\n",
"a {\n color: clamp(1);\n}\n"
);
test!(
clamp_many_args,
"a {\n color: clamp(1, 2, 3);\n}\n",
"a {\n color: clamp(1, 2, 3);\n}\n"
);