Skip to content

Instantly share code, notes, and snippets.

@jaicab
Last active August 29, 2015 14:21
Show Gist options
  • Save jaicab/16f04ff12d551b551902 to your computer and use it in GitHub Desktop.
Save jaicab/16f04ff12d551b551902 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
$bodyclass: '.bodyclass';
@mixin classmerge{
$selector-list: &;
@each $selector in $selector-list {
$others: ();
// Just html class - .htmlclass
$htmlclass: nth($selector, 1);
// If more than one element
@if(length($selector)>1){
@for $i from 2 through length($selector) {
// Add the other selectors
$others: append($others, nth($selector, $i), space);
}
}
@at-root{
/*! This should produce:
.js .bodyclass .element .active */
#{$htmlclass} {
#{unquote($bodyclass)} {
#{$others} {
@content;
}
}
}
}
@at-root{
/*! (HACK) This fixes it though, but just for this case */
html{
&#{$htmlclass} {
#{unquote($bodyclass)} {
#{$others} {
@content;
}
}
}
}
}
}
}
.js{
.element{
.active{
color: blue;
@include classmerge {
background: red;
}
}
}
}
.js .element .active {
color: blue;
}
/*! This should produce:
.js .bodyclass .element .active */
.js .element .active .js .bodyclass .element .active {
background: red;
}
/*! (HACK) This fixes it though, but just for this case */
html.js .bodyclass .element .active {
background: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment