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
Move @import rules to an extra/separate browser tag inside tags #1577
Conversation
html{color:blue;}</style> | ||
<style data-styled-components=\\"\\"> | ||
/* sc-component-id: sc-global-1433896746-import */ | ||
@import url('bla');</style>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this style tag be above the other style tags? Or is it only about the first thing in a certain style tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mxstbr I could enforce it to come before the style tag that contains the @import
actually. I'm not sure whether we'd want that, since it's mostly meant for fonts only anyway.
But I could modify the makeStyleTag
method to allow me to inject elements before another
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I mean if it works that's totally fine!
When a BrowserTag or SpeedyTag detect an @import rule, which is expected to be the first rules in the array to arrive due to Stylis' reordering, then an extra tag is injected, and the @import rules are injected there instead. This ensures that it's *impossible* for an @import rule to not be at the beginning of a stylesheet.
b084496
to
2e12f8e
Compare
2e12f8e
to
980ffc7
Compare
- Prevent creating multiple style tags for import at-rules - Create a single one a single time via the StyleSheet - Put it at the top of the other style tags
Fixes #1574
When a BrowserTag or SpeedyTag detect an @import rule, which is expected
to be the first rules in the array to arrive due to Stylis' reordering,
then an extra tag is injected, and the @import rules are injected there
instead.
This ensures that it's impossible for an @import rule to not be at the
beginning of a stylesheet.
Published under
styled-components@dev
version3.2.1-0
for testing.