Skip to content

Pseudoselectors without & prefix emit malformed CSS #323

Closed

Description

@quantizor
div {
  :hover {
    color: red;
  }
}

The above code used to work in stylis v3, but it seems since stylis v4 an ampersand is explicitly required, e.g.

div {
  &:hover {
    color: red;
  }
}

Can the prior functionality to pretend an & is there for a leading : be restored?

Activity

  1. Andarist commented on Dec 27, 2023

    @Andarist
    Collaborator

    Can the prior functionality to pretend an & is there for a leading : be restored?

    No. This was an explicit breaking change - one that fixed some old issues here. This matches the SASS/Less/etc behavior.

    In Emotion, I had to figure out how to restore the old functionality on our side and we always include a custom "compat" plugin. If you'd be interested in reusing this, I could move this to a separate package or something.

    I think I'd like to start deprecating this old behavior in Emotion soon-ish so we could ship the next major version without this plugin.

  2. quantizor commented on Dec 27, 2023

    @quantizor
    ContributorAuthor

    Got it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions