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

Inconsistent localisation of @keyframes #374

Open
deadalnix opened this issue Mar 4, 2022 · 1 comment
Open

Inconsistent localisation of @keyframes #374

deadalnix opened this issue Mar 4, 2022 · 1 comment

Comments

@deadalnix
Copy link

:global {
    @keyframes myanimation {
        // ...
    }
    
    .myclass {
        animation: myanimation  0.5s 0s;
    }
}

Will fail to proceed because the @Keyframes identifier is localized, but the substitution doesn't happen in .myclass as it is assumed identifiers are global in there. As in:

@keyframes _myanimation_HHHH {
    // ...
}

.myclass {
    animation: myanimation  0.5s 0s;
}

Which fails to produce the expected results.

When in global blocks, @Keyframes 's identifier should be treated as global, not local. If the rather strange decision is made that this should be local anyways, then translation should happen within .myclass.

@jdelStrother
Copy link

Similarly, if you use css-loader with { modules: { mode: "global" } } to default to global identifiers, but try to make a keyframe local:

:local {
  @keyframes myanimation {
      // ...
  }

  .myclass {
      myanimation 0.5s 0s;
  }
}

it outputs:

@keyframes myanimation {
  // ...
}
.styles__myclass___cl8bP {
  animation: styles__myanimation___IbkbJ 0.5s 0s;
}

You can work around that with:

@keyframes :local(myanimation) {
    // ...
}

:local {
  .myclass {
      myanimation 0.5s 0s;
  }
}

@deadalnix untested, but I wonder if you could fix your issue with:

 @keyframes :global(myanimation) {
     // ...
 }
 :global {
    .myclass {
        animation: myanimation  0.5s 0s;
    }
}

but it's a shame the keyframe identifiers don't seem to obey the global/local scope they're declared in.

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