Skip to content

stylis plugin not working for keyframes since 5.0.0-rc3 #2936 #3163

@mzvast

Description

@mzvast

Environment

System:

  • OS: macOS 10.15.5
  • CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
  • Memory: 69.18 MB / 8.00 GB
  • Shell: 5.7.1 - /bin/zsh

Binaries:

  • Node: 10.21.0 - ~/.nvm/versions/node/v10.21.0/bin/node
  • Yarn: 1.22.4 - ~/.nvm/versions/node/v10.21.0/bin/yarn
  • npm: 6.14.4 - ~/.nvm/versions/node/v10.21.0/bin/npm

Reproduction

I wrote a stylis plugin to transform px to vm.
It works fine before following commit:

image

My plugin stop working when it encounters @Keyframes mark, which can't receive any input then.

Working

workspace
image

Broken

workspace
image

Steps to reproduce

change styled-components version to greater than rc3 .

Expected Behavior

My plugin should receive @Keyframes input.

Actual Behavior

My plugin didn't receive @Keyframes input.

My attempts

I used binary searching to accurately allocate the first breaking commit.
And I spend some time to compare the behavior and output between fine version and broken version.
However, I'm not quite sure how it works, especially on following lines.

inject = (styleSheet: StyleSheet) => {
if (!styleSheet.hasNameForId(this.id, this.name)) {
styleSheet.insertRules(this.id, this.name, masterStylis(...this.stringifyArgs));
}
};

I add a debugger right here, and hit refresh.
image

To my surprise, the break point didn't hit at all. But still injected @Keyframes to style tag as below.
image

Then I comment out this line as below.And hit refresh.
image

Oh my god, it did HIT!
image

Finally, I god mad at what happened.

Maybe you think I should put a break point at

insertRules(id: string, name: string, rules: string[]) {
this.registerName(id, name);
this.getTag().insertRules(getGroupForId(id), rules);
}

It behaves strangely as well.

I need you help:)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions