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 throws error when extended directive contains media query containing referencing parent selector #943

Closed
telekid opened this issue Mar 13, 2015 · 11 comments · Fixed by #970

Comments

@telekid
Copy link

telekid commented Mar 13, 2015

test.scss

%dog {
    @media (min-width: 10px) {
        &:hover {
            display: none;
        }
    }
}

.puppy {
    @extend %dog;
    background-color: red;
}

Throws error in libsass:

{
  "message": "You may not @extend an outer selector from within @media.\nYou may only @extend selectors within the same directive.\nFrom \"@extend %dog\" on line 10 of test.scss\n",
  "column": 14,
  "line": 3,
  "file": "/Users/jake/Development/bug-test/test.scss",
  "status": 1
}

But correctly generates the following in Ruby Sass 3.4.13 (Selective Steve):

@media (min-width: 10px) {
  .puppy:hover {
    display: none; } }

.puppy {
  background-color: red; }

Note that I'm using libsass 3.2.x through this fork of node-sass:
CandoImage/node-sass@d2b9b88

mgreter added a commit to mgreter/libsass that referenced this issue Mar 14, 2015
@mgreter mgreter added this to the 3.2 milestone Mar 14, 2015
@mgreter mgreter self-assigned this Mar 14, 2015
@drewwells
Copy link
Contributor

👍 commit fixed @extend errors

@Awem
Copy link

Awem commented Mar 31, 2015

@xzyfer
Copy link
Contributor

xzyfer commented Apr 1, 2015

The fix for this is only in Libsass >= 3.2.0-beta.3, and not in any node-sass release.

If you can reproduce this issue in [email protected] please let us know and we will reopen this issue.

@dalvarez
Copy link

dalvarez commented Apr 1, 2015

@krzkrzkrz I'm getting the same issue to (using broccoli-sass in an ember-cli project)

@krzkrzkrz
Copy link

I am using broccoli-sass in an Ember CLI app (v0.2.2). I seems broccoli-sass is using libsass, I get:

You may not @extend an outer selector from within @media.
You may only @extend selectors within the same directive.
From "@extend .input-sm" on line 48 of tmp/tree_merger-tmp_dest_dir-VAbune7B.tmp/app/styles/bootstrap/_input-groups.scss

Downgrading broccoli-sass to a previous version (0.6.2) doesn't render any issues:

npm uninstall --save-dev broccoli-sass
npm cache clean
npm install --save-dev [email protected]

Reference: joliss/broccoli-sass#59 (comment)

@Awem
Copy link

Awem commented Apr 1, 2015

@krzkrzkrz broccoli-sass uses libsass via node-sass, which is still using 3.2.0-beta.2

@dalvarez
Copy link

dalvarez commented Apr 1, 2015

@krzkrzkrz that fixed it for me too - when you uninstall and then reinstall, it switches node-sass version to [email protected] which doesn't have the bug.

@krzkrzkrz
Copy link

@AW-UC should I report this on the node-sass repo as well?

@dalvarez glad to hear

@Awem
Copy link

Awem commented Apr 1, 2015

@krzkrzkrz no, it's already reported.

@ghost
Copy link

ghost commented Jan 17, 2017

@xzyfer I still got issues where '@extend' doesn't work while using the following

"node-sass": "^4.1.1"

@xzyfer
Copy link
Contributor

xzyfer commented Jan 17, 2017

@ajjublr please don't comment on closed issues. Create a new issue showing the extend code that isn't working.

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

Successfully merging a pull request may close this issue.

7 participants