Skip to content

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

@FWSimon

Description

@FWSimon

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

Activity

chriseppstein

chriseppstein commented on Oct 29, 2015

@chriseppstein

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

FWSimon commented on Oct 30, 2015

@FWSimon
Author

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

KEMBL

KEMBL commented on May 16, 2018

@KEMBL

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chriseppstein@KEMBL@FWSimon

        Issue actions

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