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

[Emotion] Squash :first-child/:nth-child errors #5920

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion scripts/jest/setup/throw_on_console_error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// Fail if a test ends up `console.error`-ing, e.g. if React logs because of a
// failed prop types check.
console.error = message => {
console.error = (message) => {
// @see https://github.com/emotion-js/emotion/issues/1105
// This error that Emotion throws doesn't apply to Jest, so
// we're just going to straight up ignore the first/nth-child warning
if (
typeof message === 'string' &&
message.includes('The pseudo class') &&
message.includes(
'is potentially unsafe when doing server-side rendering. Try changing it to'
)
) {
return;
}

throw new Error(message);
};
1 change: 1 addition & 0 deletions src-docs/src/components/codesandbox/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const cache = createCache({
key: 'codesandbox',
container: document.querySelector('meta[name="emotion-styles"]'),
});
cache.compat = true;

ReactDOM.render(
<EuiProvider cache={cache} ${providerProps}>
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/app_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const emotionCache = createCache({
key: 'eui-docs',
container: document.querySelector('meta[name="emotion-styles"]'),
});
emotionCache.compat = true;

export const AppContext = ({ children }) => {
const { theme } = useContext(ThemeContext);
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/provider/provider_styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const cache = createCache({
key: 'myApp',
container: document.querySelector('meta[name="emotion-style-insert"]'),
});
cache.compat = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompsongl this is used in our demo JS example - do we want consumers to copy this .compat = true code or no? It's possible some consumers may be on SSR and actually want the warning?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave this in. Even with SSR the warnings aren't helpful.


<EuiProvider${colorMode === 'DARK' ? ' colorMode="dark"' : ''} cache={cache}'>
{/* Content */}
Expand Down