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

rulesheet middleware skips empty @keyframes #265

Closed
michal-perlakowski opened this issue May 27, 2021 · 1 comment
Closed

rulesheet middleware skips empty @keyframes #265

michal-perlakowski opened this issue May 27, 2021 · 1 comment

Comments

@michal-perlakowski
Copy link

serialize(compile('@keyframes test-animation {}'), middleware([
  stringify,
  rulesheet((rule) => {
    console.log(rule);
  })
]));

Expected behavior: @keyframes test-animation {} is logged in console. Current behavior: nothing is logged.

Use case: Material-UI uses empty animations to detect autofill in text fields (see the issue in Material-UI).

@Andarist
Copy link
Collaborator

@thysultan I'm slightly on the fence here but I'm leaning towards being in favor of handling this in Stylis. I feel like the main reason why we don't inject empty rules is that we always end up with a slot for rules in the output, even if there are no rules for this particular level of nesting. This happens because we don't lookahead to check if there are any rules ahead of us (doing that would be obviously bad) nor we don't want to track if the slot has been already created or not - it's always created roughly when { gets encountered and this simplifies the code that follows that.

This makes sense for regular rules but @keyframes are conceptually different - they are always "top-level" rules, so if one writes a definition for them then it might act as a clear signal that the output for it should be produced.

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

Successfully merging a pull request may close this issue.

2 participants