disallow selectors and styles in functions

This commit is contained in:
Connor Skees 2020-08-03 01:18:00 -04:00
parent 3e5f69118b
commit 622d44ac63
2 changed files with 20 additions and 0 deletions

View File

@ -245,6 +245,13 @@ impl<'a> Parser<'a> {
// dart-sass seems to special-case the error message here? // dart-sass seems to special-case the error message here?
'!' | '{' => return Err(("expected \"}\".", *pos).into()), '!' | '{' => return Err(("expected \"}\".", *pos).into()),
_ => { _ => {
if self.flags.in_function() {
return Err((
"Functions can only contain variable declarations and control directives.",
self.span_before
)
.into());
}
if self.flags.in_keyframes() { if self.flags.in_keyframes() {
match self.is_selector_or_style()? { match self.is_selector_or_style()? {
SelectorOrStyle::Style(property, value) => { SelectorOrStyle::Style(property, value) => {

View File

@ -305,3 +305,16 @@ error!(
}", }",
"Error: This at-rule is not allowed here." "Error: This at-rule is not allowed here."
); );
error!(
disallows_selectors,
"@function foo($a) {
functiona {
@return $a;
}
}
a {
color: foo(nul);
}",
"Error: Functions can only contain variable declarations and control directives."
);