Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created March 2, 2012 10:02
Show Gist options
  • Save mahmoud/1957471 to your computer and use it in GitHub Desktop.
Save mahmoud/1957471 to your computer and use it in GitHub Desktop.
less css scoping test
@test: 0;
.mixin() when (@test = 0) { background: blue !important; }
.mixin() when (@test = 1) { @test: 2; background: red !important; }
.mixin() when (@test = 2) { background: black !important; }
body {
@test: 1;
.mixin;
.mixin;
}
// body ends up being red meaning:
// a) scope of conditional mixins (guard expressions) is looked up from the calling point, not the declaration point (a good thing), and
// b) can't change nonlocal variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment