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

fix(SSR): change the unreliable pseudo class ":first-child" to ":first-of-type" #253

Merged
merged 15 commits into from
Nov 6, 2020

Conversation

cheton
Copy link
Member

@cheton cheton commented Nov 5, 2020

Problem description

In emotion v10+, a new warning is thrown if you use :first-child, :nth-child, or :nth-last-child selectors in a styled component or css prop value. This is because, when using SSR, the style element is injected immediately above (prepended) the associated component.

Problems surrounding SSR injection of <style> and unreliability of :first-child selectors
emotion-js/emotion#1178

Suggested workaround

Changing the unreliable pseudo class :first-child to :first-of-type. This only works if all sibling elements are of the same type.

@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@cheton cheton requested review from tinaClin, roth1002, austinhung81 and joshuatai and removed request for roth1002 November 5, 2020 09:11
@cheton cheton removed the 🏗️ work in progress Work in progress label Nov 5, 2020
@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@trendmicro-frontend-bot
Copy link
Contributor

@joyfulelement
Copy link

joyfulelement commented Nov 6, 2020

This issue has been reported by at least three Cloud One service frontend teams (C1C, CS, FSS) and all waiting on this fix.
e.g. when Modal Window is opened.

Thank you style UI team for making this fix available 🚀 👍

@trendmicro-frontend-bot
Copy link
Contributor

@cheton cheton merged commit 7a9cc8a into master Nov 6, 2020
@cheton cheton deleted the feat/ssr-first-child branch November 6, 2020 02:13
@cheton
Copy link
Member Author

cheton commented Nov 6, 2020

Published @trendmicro/[email protected] to NPM

https://www.npmjs.com/package/@trendmicro/react-styled-ui/v/0.9.3

cc @joyfulelement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👷 refactor (improvement) Improvements in the code base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants