Lawrence
Lawrence

Reputation: 845

Sass "@at-root" not working

Currently I have sass 3.3 installed but I am using compass to compile. The question at hand is , I have the following two mixins to do bem syntax:

//elements get appended with "__" and the $name
=e($name)
    @at-root &__#{$name}
        @content

//modifiers get appended with "--" and the $name
=m($name)
    @at-root &--#{$name}
        @content

In use:

.blocker
    +e(item)
        color: red

Output:

.blocker {
  @at-root &__item {
    color: blue;
}

}

Why is it not working?

Upvotes: 1

Views: 2160

Answers (1)

MStrutt
MStrutt

Reputation: 819

I tried your mixin out an it seems to work fine, however, using the updated sass syntax, you don't need a mixin or @at-root to achieve this

.blocker
    &__item
        color: red 
    &--mod
        color: blue

will compile to

.blocker__item {
    color: blue;
}
.blocker--mod {
    color: red;
}

If you want to try out the sass code itself, independently of your environment, take a look at SassMeister.

Upvotes: 2

Related Questions