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

Prevent ServerStyleSheet generating empty style tags/elements #4327

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hamidrezahanafi
Copy link

It seems like this PR not ported over to v6 and with React 18 streaming, it's possible to insert empty style tag in middle of html.
It should fix this issue: #4289

Ported over from: b9e60f7

@hamidrezahanafi hamidrezahanafi changed the title Prevent _emitSheetCSS to generate empty style tags Prevent ServerStyleSheet to generate empty style tags/elements Jun 8, 2024
@hamidrezahanafi hamidrezahanafi changed the title Prevent ServerStyleSheet to generate empty style tags/elements Prevent ServerStyleSheet generating empty style tags/elements Jun 8, 2024
@hamidrezahanafi
Copy link
Author

@quantizor would you please take a look at this one? It's going to save much of headaches with SSR

@@ -16,7 +16,7 @@ export const outputSheet = (sheet: Sheet) => {

const names = sheet.names.get(id);
const rules = tag.getGroup(group);
if (names === undefined || rules.length === 0) continue;
if (names === undefined || !names.size || rules.length === 0) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this change w.r.t. createGlobalStyle. Could you add a test verifying that cGS usage without any other components works as expected in SSR?

Copy link
Author

Choose a reason for hiding this comment

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

Test added

@quantizor
Copy link
Contributor

Awesome, looks good. Can you settle the prettier job and then I'll approve?

@hamidrezahanafi
Copy link
Author

Awesome, looks good. Can you settle the prettier job and then I'll approve?

Done thank you for looking into this!

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

2 participants