Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@extend in media query compiles outside of media query #673

Closed
Veraxus opened this issue Nov 24, 2014 · 4 comments
Closed

@extend in media query compiles outside of media query #673

Veraxus opened this issue Nov 24, 2014 · 4 comments

Comments

@Veraxus
Copy link

Veraxus commented Nov 24, 2014

If I @extend a class within a media query, the CSS compiles outside the media query and aggregated with the global scope class. This is... weird... and it makes using @extend on classes pretty much worthless on mobile-first projects.

SCSS

.example {
    padding-left: 2rem;
    padding-right: 2rem;
}
@media screen and (min-width:768px) {

    #footer {
        .row {
            @extend .example;
        }
    }

}

EXPECTED CSS

.example {
    padding-left: 2rem;
    padding-right: 2rem;
}
@media screen and (min-width:768px) {

    #footer .row {
        padding-left: 2rem;
        padding-right: 2rem;
    }

}

ACTUAL CSS

.example, #footer .row {
    padding-left: 2rem;
    padding-right: 2rem;
}
@xzyfer
Copy link
Contributor

xzyfer commented Nov 24, 2014

Thanks for reporting this.

Could you please add a spec in https://github.com/sass/sass-spec ?

Here's an example of a good spec PR for reference https://github.com/sass/sass-spec/pull/89/files

@Panya
Copy link

Panya commented Nov 24, 2014

Well, as I know in Ruby Sass you cannot use @extend inside @media that way (extending a selector that outside the @media's block). You'll get an error.

@Veraxus
Copy link
Author

Veraxus commented Nov 24, 2014

It turns out that this behavior has been (controversially) deprecated and removed as of SASS 3.3. Please disregard this issue. Different approaches are recommended instead.

For more information, see: sass/sass#456

@Veraxus Veraxus closed this as completed Nov 24, 2014
@montoya-azul
Copy link

What is a better approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants