Skip to content

Unique components receive non-unique classnames #609

Description

@mindplay-dk

I was trying out goober and quickly ran into problems with nested selectors - have a look here:

https://stackblitz.com/edit/vitejs-vite-zbyg2anw?file=src%2FApp.tsx

The letters should turn red, green, blue and yellow when hovering - instead, the red/green/blue hover states all turn blue.

It looks like this is due to colliding hashes:

Image

For this simple example, you can fix it by making sure the styles are non-unique, e.g.:

const R = styled('div')`
  color: gray;
`;

const G = styled('div')`
  color: darkgray;
`;

const B = styled('div')`
  color: lightgray;
`;

If unique components don't get a unique hash, you can't override them individually, as I'm trying to do in this example.

To ensure that unique components get unique class-names, probably the component ID should figure into the hash?

e.g. a global component ID counter being used to assign a unique ID to every styled component, and then including that in the hash?

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