deny mixins in functions, control flow, and mixins
This commit is contained in:
parent
005f0e52e8
commit
b4bdd2f926
@ -18,6 +18,19 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn parse_mixin(&mut self) -> SassResult<()> {
|
||||
self.whitespace();
|
||||
let Spanned { node: name, span } = self.parse_identifier()?;
|
||||
|
||||
if self.flags.in_mixin() {
|
||||
return Err(("Mixins may not contain mixin declarations.", span).into());
|
||||
}
|
||||
|
||||
if self.flags.in_function() {
|
||||
return Err(("This at-rule is not allowed here.", span).into());
|
||||
}
|
||||
|
||||
if self.flags.in_control_flow() {
|
||||
return Err(("Mixins may not be declared in control directives.", span).into());
|
||||
}
|
||||
|
||||
self.whitespace();
|
||||
let args = match self.toks.next() {
|
||||
Some(Token { kind: '(', .. }) => self.parse_func_args()?,
|
||||
|
@ -449,3 +449,32 @@ test!(
|
||||
}",
|
||||
"a {\n color: foo;\n color: foo;\n}\n"
|
||||
);
|
||||
error!(
|
||||
mixin_in_function,
|
||||
"@function foo() {
|
||||
@mixin bar {}
|
||||
}
|
||||
a {
|
||||
color: foo();
|
||||
}
|
||||
",
|
||||
"Error: This at-rule is not allowed here."
|
||||
);
|
||||
error!(
|
||||
mixin_in_mixin,
|
||||
"@mixin foo {
|
||||
@mixin bar {}
|
||||
}
|
||||
a {
|
||||
@include foo;
|
||||
}
|
||||
",
|
||||
"Error: Mixins may not contain mixin declarations."
|
||||
);
|
||||
error!(
|
||||
mixin_in_control_directives,
|
||||
"@if true {
|
||||
@mixin bar {}
|
||||
}",
|
||||
"Error: Mixins may not be declared in control directives."
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user