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

prefixer middleware does not copy element type #262

Closed
quantizor opened this issue May 5, 2021 · 4 comments
Closed

prefixer middleware does not copy element type #262

quantizor opened this issue May 5, 2021 · 4 comments

Comments

@quantizor
Copy link
Contributor

quantizor commented May 5, 2021

When running prefixer over an element node like a keyframes object, the prefixed version is created but element.type is not set to "@keyframes", it gets set to an empty string

@thysultan
Copy link
Owner

Example code?

@quantizor
Copy link
Contributor Author

quantizor commented May 5, 2021

import { compile, Middleware, middleware, prefixer, serialize, stringify } from 'stylis';

const stylis = (css: string, extraPlugins: Middleware[] = []) =>
  serialize(compile(css), middleware([...extraPlugins, stringify]));

stylis(
  `@keyframes a {
    0% { left: 0px; }
    100% { left: 100px; }
  }
`,
  [prefixer]
)

The new keyframe rule generated by the prefixer plugin has element.type set to empty string instead of "@keyframes"

@Andarist
Copy link
Collaborator

Andarist commented May 5, 2021

Just a note about the current implementation - the third argument passed here is for the type and it is set to '':
https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Middleware.js#L48

Looking into the codebase - all calls to copy pass an empty string there.

@thysultan
Copy link
Owner

Pending accidental fix with the next patch i'm working on.

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

3 participants