Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Not all @nest at-rules are transformed #40

Closed
priver opened this issue Jul 10, 2017 · 3 comments
Closed

Not all @nest at-rules are transformed #40

priver opened this issue Jul 10, 2017 · 3 comments

Comments

@priver
Copy link

priver commented Jul 10, 2017

Version of postcss-nesting: 4.0.1

Input:

.a {
  color: black;
  @nest .a1 & {color: red;}
  @nest .a2 & {color: blue;}
  @nest .a3 & {color: green;}
  @nest .a4 & {color: yellow;}
}

.b {
  color: black;
  @nest .b1 & {color: red;}
  @nest .b2 & {color: blue;}
  @nest .b3 & {color: green;}
  @nest .b4 & {color: yellow;}
}

Output:

.a {
  color: black
}

.a1 .a {
  color: red
}

.a2 .a {
  color: blue
}

.a {

  @nest .a3 & {color: green;
  }

  @nest .a4 & {color: yellow;
  }
}

.b {
  color: black;
  @nest .b1 & {color: red;}
  @nest .b2 & {color: blue;}
  @nest .b3 & {color: green;}
  @nest .b4 & {color: yellow;}
}

Expected:

.a {
  color: black
}

.a1 .a {
  color: red
}

.a2 .a {
  color: blue
}

.a3 .a {
  color: green
}

.a4 .a {
  color: yellow
}

.b {
  color: black
}

.b1 .b {
  color: red
}

.b2 .b {
  color: blue
}

.b3 .b {
  color: green
}

.b4 .b {
  color: yellow
}
@woble
Copy link

woble commented Jul 20, 2017

Any update on this? 🤔

@priver priver changed the title Not all @nest at-rules transformed Not all @nest at-rules are transformed Jul 20, 2017
@woble
Copy link

woble commented Jul 25, 2017

Here's another simplified example that doesn't work with the latest version.

Input

::-webkit-scrollbar {
    @nest
    body:not(.macos) & {
        background-color: white;
    }

    @nest
    .secondary & {
        @nest
        body:not(.macos) & {
            background-color: black;
        }
    }

    @nest
    .primary & {
        @nest
        body:not(.macos) & {
            background-color: white;
        }
    }
}

Output

body:not(.macos) .foo {
    background-color: white
}

.foo {
    @nest .secondary & {
        @nest body,
        not(.macos) & {
            background-color: black
        }
    }
    @nest .primary & {
        @nest body,
        not(.macos) & {
            background-color: white
        }
    }
}

@jonathantneal
Copy link
Collaborator

Fixed by #45

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

No branches or pull requests

3 participants