allow vendor prefixed special css functions

This commit is contained in:
Connor Skees 2020-08-02 14:52:46 -04:00
parent da3c3eabfc
commit 6189810ced
3 changed files with 22 additions and 2 deletions

View File

@ -11,7 +11,7 @@ use peekmore::{PeekMore, PeekMoreIterator};
use crate::{
builtin::GLOBAL_FUNCTIONS,
color::{Color, NAMED_COLORS},
common::{Brackets, Identifier, ListSeparator, Op, QuoteKind},
common::{unvendor, Brackets, Identifier, ListSeparator, Op, QuoteKind},
error::SassResult,
unit::Unit,
utils::{
@ -301,7 +301,7 @@ impl<'a> Parser<'a> {
.span(span));
} else {
// check for special cased CSS functions
match lower.as_str() {
match unvendor(&lower) {
"calc" | "element" | "expression" => {
s = lower;
self.parse_calc_args(&mut s)?;

View File

@ -46,6 +46,11 @@ test!(
"a {\n color: cAlC(1 + 1);\n}\n",
"a {\n color: calc(1 + 1);\n}\n"
);
test!(
calc_browser_prefixed,
"a {\n color: -webkit-calc(1 + 2);\n}\n",
"a {\n color: -webkit-calc(1 + 2);\n}\n"
);
test!(
element_whitespace,
"a {\n color: element( 1 );\n}\n",
@ -81,6 +86,11 @@ test!(
element_nested_parens,
"a {\n color: element((((()))));\n}\n"
);
test!(
element_browser_prefixed,
"a {\n color: -webkit-element(1 + 2);\n}\n",
"a {\n color: -webkit-element(1 + 2);\n}\n"
);
test!(
expression_whitespace,
"a {\n color: expression( 1 );\n}\n",
@ -116,6 +126,11 @@ test!(
expression_nested_parens,
"a {\n color: expression((((()))));\n}\n"
);
test!(
expression_browser_prefixed,
"a {\n color: -webkit-expression(1 + 2);\n}\n",
"a {\n color: -webkit-expression(1 + 2);\n}\n"
);
test!(
progid_whitespace,
"a {\n color: progid:( 1 );\n}\n",

View File

@ -134,6 +134,11 @@ test!(
"a {\n color: UrL(http://foo);\n}\n",
"a {\n color: url(http://foo);\n}\n"
);
test!(
url_browser_prefixed,
"a {\n color: -webkit-url(https://google.com);\n}\n",
"a {\n color: url(https://google.com);\n}\n"
);
error!(
url_nothing_after_forward_slash_in_interpolation,
"a { color: url(#{/", "Error: Expected expression."