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

Breaks CSS pseudo-class inside a template literal #691

Open
brodycj opened this issue Aug 26, 2021 · 0 comments
Open

Breaks CSS pseudo-class inside a template literal #691

brodycj opened this issue Aug 26, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@brodycj
Copy link
Owner

brodycj commented Aug 26, 2021

prettier/prettier#11400:

Prettier 2.3.2
Playground link

--parser babel

Input:

const focus = true ? 'focus-visible' : 'focus';
const styles = css`
  /* A space is inserted after the ':' which breaks the pseudoclass */
  .content:${focus} {
    border-color: red;
  }
`;

Output:

const focus = true ? "focus-visible" : "focus";
const styles = css`
  /* A space is inserted after the ':' which breaks the pseudoclass */
  .content: ${focus} {
    border-color: red;
  }
`;

ugly workaround from @brodybits:

Prettier 2.3.2
Playground link

--parser babel

Input:

const focus = true ? 'focus-visible' : 'focus';
const styles = css`
  ${`.content:${focus}`} {
    border-color: red;
  }
`;

Output:

const focus = true ? "focus-visible" : "focus";
const styles = css`
  ${`.content:${focus}`} {
    border-color: red;
  }
`;
@brodycj brodycj added the bug Something isn't working label Aug 26, 2021
@brodycj brodycj self-assigned this Aug 26, 2021
@brodycj brodycj changed the title Embedded CSS pseudo-class inside a template literal Breaks CSS pseudo-class inside a template literal Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant