diff --git a/src/color/mod.rs b/src/color/mod.rs index 4195be4..38db906 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -370,7 +370,7 @@ impl Color { /// Create RGBA representation from HSLA values pub fn from_hsla(hue: Number, saturation: Number, luminance: Number, alpha: Number) -> Self { - let mut hue = if hue > Number::from(360) { + let mut hue = if hue >= Number::from(360) { hue % Number::from(360) } else if hue < Number::from(-360) { Number::from(360) + hue % Number::from(360) diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index d58d37a..71d03db 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -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::{ @@ -343,7 +343,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)?; diff --git a/tests/color.rs b/tests/color.rs index 3fa4968..86bd048 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -247,6 +247,11 @@ test!( "a {\n color: hue(rgb(1, 0, 1));\n}\n", "a {\n color: 300deg;\n}\n" ); +test!( + hue_of_360_becomes_0, + "a {\n color: hue(hsl(360, 10%, 20%));\n}\n", + "a {\n color: 0deg;\n}\n" +); test!( hue_green_equals_blue, "a {\n color: hue(rgb(0, 1, 1));\n}\n", diff --git a/tests/special-functions.rs b/tests/special-functions.rs index a60452b..8ec9a55 100644 --- a/tests/special-functions.rs +++ b/tests/special-functions.rs @@ -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", diff --git a/tests/url.rs b/tests/url.rs index 0373825..5228f07 100644 --- a/tests/url.rs +++ b/tests/url.rs @@ -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."