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

Missing CSS module renaming for nested @keyframes #450

Closed
joelmoss opened this issue Mar 23, 2023 · 4 comments
Closed

Missing CSS module renaming for nested @keyframes #450

joelmoss opened this issue Mar 23, 2023 · 4 comments

Comments

@joelmoss
Copy link
Contributor

I have the following CSS which has a nested @keyframes:

.loading {
  animation: ball;

  @keyframes ball {
    0% {
      transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
      transform: translate(-50%, -50%) rotate(360deg);
    }
  }
}

Passing this to lightningcss with nesting and css modules enabled gives me this out ouput:

.EgL3uq_loading {
  animation: EgL3uq_ball;
  @keyframes ball {
    0% {
      transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
      transform: translate(-50%, -50%) rotate(360deg);
    }
  }
}

Which as you can see, renames the ball keyframe when it is used, but does not rename the actual declaration.

Un-nesting the @keyframe results in correctly renaming both the call and the declaration.

thx

@devongovett
Copy link
Member

Hmm I'm not sure nesting key frames is valid? I think only conditional rules like media, supports, and layer can be nested.

@joelmoss
Copy link
Contributor Author

Yeah I think you may be right. However, if that is true, the keyframe should probably not be renamed.

Declaring the keyframe within the CSS module (but not nested) does end up renamed. So all is fine. But if the keyframe is declared outside the CSS module (global), then the declaration is obviously not renamed, but the calling code within the CSS module does rename it.

@devongovett
Copy link
Member

Yeah there's currently no way to reference a global identifier like you can use :global(.foo) in a selector. Haven't seen a good syntax for that yet.

@devongovett
Copy link
Member

Looks like there is already a warning for this - example.

I also made a proposal to css modules to enable referencing global identifiers: css-modules/css-modules#390. Going to close this issue since that is tracked elsewhere.

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