lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Ligthning generate :is with pseudo element

Open bakura10 opened this issue 3 years ago • 5 comments

Hi,

Considering the following code:

.foo {
  &::before {
    .bar & {
      color: blue;
    }
  }
}

ParcelCSS will generate the following CSS:

.bar :is(.foo:before){color:#00f}

Playground URL

However, using a pseudo element selector is not valid inside :is, so it should generate this instead:

.bar .foo:before{color:#00f}

bakura10 avatar Dec 08 '22 07:12 bakura10

Actually I'm not convinced that this is valid for nesting either... https://drafts.csswg.org/css-nesting/#example-7145ff1e

Related: https://github.com/w3c/csswg-drafts/issues/7433

devongovett avatar Dec 08 '22 15:12 devongovett

It seems you're right, this is a very odd limitation. Maybe Parcel should emit a warning here, I can imagine I won't be the first being caught by surprise here :D

bakura10 avatar Dec 09 '22 01:12 bakura10

For lightningcss 1.0.0-alpha.55, the double semicolon :: of psuedo-element selector will always be transformed to single semicolon : (as psuedo-class selector) during bundle process regardless of browserslist. This doesn't make sense especially when the --minify option is not used.

fuweichin avatar May 27 '24 00:05 fuweichin

It seems you're right, this is a very odd limitation. Maybe Parcel should emit a warning here, I can imagine I won't be the first being caught by surprise here :D

I filed a separate issue: https://github.com/parcel-bundler/lightningcss/issues/760

yisibl avatar Jun 20 '24 10:06 yisibl

For the following styles

input

dialog:modal, dialog:modal::backdrop {
  @starting-style {
    opacity: 0;
  }
  opacity: 1;
}

output

dialog:modal {
  opacity: 1;
}

@starting-style {
  dialog:modal {
    opacity: 0;
  }
}

dialog:modal::backdrop {
  opacity: 1;
}

@starting-style {
  dialog:modal::backdrop {
    opacity: 0;
  }
}

expected

dialog:modal, dialog:modal::backdrop {
  opacity: 1;
}
@starting-style {
  dialog:modal, dialog:modal::backdrop {
    opacity: 0;
  }
}

yisibl avatar Jun 20 '24 10:06 yisibl