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

Unexpected scoping with pseudo selectors #267

Closed
nstepien opened this issue Jun 22, 2021 · 1 comment
Closed

Unexpected scoping with pseudo selectors #267

nstepien opened this issue Jun 22, 2021 · 1 comment

Comments

@nstepien
Copy link

See callstack/linaria#782


input:

css`
  .a {
    .b & {
      color: blue;
    }
  }
`;

css`
  .c {
    :hover & {
      color: red;
    }
  }
`;

output:

.b .s1waqsbb .a {
  color: #00f;
}

.syp60te .c:hover .syp60te .c {
  color: red;
}

I expect the & to take precedence, so it should be

-.syp60te .c:hover .syp60te .c {
+:hover .syp60te .c {

input:

const parentA = css``;
const parentB = css``;
const parentC = css``;
const activeLink = css``;

const link = css`
  all: unset;

  :is(:hover, :focus, .${activeLink}) {
    color: red;

    :is(.${parentA}, .${parentB}) & {
      content: '';
    }

    .${parentC} & {
      color: blue;
    }
  }
`;

output:

.lc7u01 {
  all: unset;
}

.lc7u01:is(:hover, :focus, .a1lslk66) {
  color: red;
}

.lc7u01:is(:hover, :focus, .a1lslk66):is(.p1waqsbb, .pyp60te) .lc7u01:is(:hover, :focus, .a1lslk66) {
  content: \"\";
}

.p4g1w4s .lc7u01:is(:hover, :focus, .a1lslk66) {
  color: #00f;
}

I expect this instead

-.lc7u01:is(:hover, :focus, .a1lslk66):is(.p1waqsbb, .pyp60te) .lc7u01:is(:hover, :focus, .a1lslk66) {
+:is(.p1waqsbb, .pyp60te) .lc7u01:is(:hover, :focus, .a1lslk66) {

I know I can do .${parentA} &, .${parentB} & {}, but that defeats the optimizations :is() offers.

Using :global() does not help: callstack/linaria#782 (comment)


Is that expected?

@thysultan
Copy link
Owner

This works as you suggest now, maybe a patch was introduced between then and now that fixed.

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

No branches or pull requests

2 participants