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

Move @import rules to an extra/separate browser tag inside tags #1577

Merged
merged 4 commits into from Mar 7, 2018

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 6, 2018

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 version 3.2.1-0 for testing.

@kitten kitten requested review from quantizor and mxstbr March 6, 2018 13:46
html{color:blue;}</style>
<style data-styled-components=\\"\\">
/* sc-component-id: sc-global-1433896746-import */
@import url('bla');</style>"
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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!

@kitten kitten changed the title Recursively add @import rules to an extra/separate browser tag Move @import rules to an extra/separate browser tag inside tags Mar 6, 2018
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.
quantizor
quantizor previously approved these changes Mar 7, 2018
- 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
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 this pull request may close these issues.

None yet

3 participants