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

Base-level rules cannot contain the parent-selector-referencing character '&'. #1873

Closed
FWSimon opened this issue Oct 28, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@FWSimon
Copy link

commented Oct 28, 2015

Hey guys,

after updating sass i got this error
Error: Base-level rules cannot contain the parent-selector-referencing character '&'.

The line it tells me is for this code

&:focus {
  outline: none;
}

What can it be? it worked before i updated sass

@chriseppstein

This comment has been minimized.

Copy link
Member

commented Oct 29, 2015

This error has existed since 3.0 which was released in May 2010.

It's nonsensical to refer to a parent selector at the base-level of a stylesheet. Inferring that & should be the universal selector at the root level is not at all a safe assumption. Additionally, this is often indicative of a coding mistake. So we consider it an error.

If this was part of a mixin that is sometimes included at the base level and sometimes nested, you can write the mixin like this:

@mixin break-accessibility {
  #{if(&, "&", "*")}:focus {
    outline: none;
  }
}
@include break-accessibility;
.foo {@include break-accessibility;}
@FWSimon

This comment has been minimized.

Copy link
Author

commented Oct 30, 2015

Ah thanks, just funny it first error out after i updated :)

@KEMBL

This comment has been minimized.

Copy link

commented May 16, 2018

I've got that error when moved from "node-sass": "4.7.2" to "node-sass": "4.9.0", so if you need your working project urgently you can set up your previous version in devDependencies in package.json and continue to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.