Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Created February 9, 2015 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blainerobison/94106e7e50d413a5b2a0 to your computer and use it in GitHub Desktop.
Save blainerobison/94106e7e50d413a5b2a0 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.11)
// Compass (v1.0.3)
// ----
// Your Example
#id > .element {
#{selector-unify(&, div)} {
color: blue;
}
}
// My Proposed Example
#id {
> .element {
@at-root #{selector-replace(&, '.element', 'div.element')} {
color: blue;
}
}
}
#id > .element #id > div.element {
color: blue;
}
#id > div.element {
color: blue;
}
@doolez
Copy link

doolez commented Jan 29, 2023

With

.parent {
  .child {
    @at-root #{selector-replace(&, '.child', '.class .child')} {
        color: red;
    }
  }
}

I get this instead:

.parent .class .child,
.class .parent .child {
  color: red;
}

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