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

Nested selectors don't work if the parent doesn't contains at least one CSS declaration #255

Closed
silvenon opened this issue Aug 12, 2017 · 0 comments · Fixed by #256
Closed

Comments

@silvenon
Copy link
Contributor

silvenon commented Aug 12, 2017

  • emotion version: 7.0.13

I wanted to apply a style to all elements of class foo that are inside bar:

import { css } from 'emotion';

const foo = css`
  color: blue;
`;
const bar = css`
  & .${foo} {
    color: red;
  }
`;

but instead this was all of the output styles:

.css-bithoy{color:blue;}

as if I wrote this:

const foo = css`
  color: blue;
`;
const bar = css`
  ${foo};
`;

However, if I add a declaration for bar:

const bar = css`
  color: black;
  & .${foo} {
    color: red;
  }
`;

it works as expected:

.css-bithoy{color:blue;}
.css-6fp6m3{color:black;}
.css-6fp6m3 .css-bithoy{color:red;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants