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

Update server-side-rendering to include style[data-cmpld] #1745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 8 additions & 5 deletions website/packages/docs/src/pages/server-side-rendering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ like so:

<!-- prettier-ignore -->
```html
<style>._k48pni7l{font-weight:600}</style>
<style data-cmpld=true>._k48pni7l{font-weight:600}</style>
Copy link
Collaborator

Choose a reason for hiding this comment

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

data-cmpld=true should be data-cmpld="true"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Screenshot 2024-12-19 at 11 55 38

<div class="_k48pni7l">
<style>._syaz18rw{color:#ff5630}</style>
<style data-cmpld=true>._syaz18rw{color:#ff5630}</style>
<div class="_syaz18rw">hello world</div>
</div>
```
Expand All @@ -40,9 +40,9 @@ resulting in less styles rendered initially:

<!-- prettier-ignore -->
```html
<style>._k48pni7l{margin-top:24px}</style>
<style data-cmpld=true>._k48pni7l{margin-top:24px}</style>
<div class="_k48pni7l">
<style>._syaz18rw{color:#ff5630}</style>
<style data-cmpld=true>._syaz18rw{color:#ff5630}</style>
<div class="_k48pni7l _syaz18rw">hello world</div>
<div class="_k48pni7l _syaz18rw">hello world</div>
<div class="_k48pni7l _syaz18rw">hello world</div>
Expand Down Expand Up @@ -83,7 +83,10 @@ Here we target the `:first-child` element.
But the text isn't red before the JavaScript has executed!

To workaround this we can use a different selector,
either `:first-of-type` or explicitly marking the first child with a [data attribute](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).
by using one of the following:
- `:first-of-type`
- explicitly marking the first child with a [data attribute](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes)
- explicitly excluding the inline `style` elements with `:not(style[data-cmpld])`

```jsx
<div css={{
Expand Down
Loading