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

CSS class names are a function of the style object #34

Merged
merged 3 commits into from
Aug 19, 2014
Merged

CSS class names are a function of the style object #34

merged 3 commits into from
Aug 19, 2014

Conversation

charliermarsh
Copy link
Collaborator

Resolves #32.

I used sha1 to mirror the way we've done this in the past, but I think that we should replace it with either a fast, non-cryptographically secure hash (like murmur), or even a checksum algorithm (like Adler-32--which React uses to compare client- and server-side markup (granted, collisions there are less important than they are here)--or CRC32). Thoughts?

Another thing to note: before, if we'd already seen styleObj in the global registry, we didn't return anything, which isn't really expected behaviour. Now, we return a style object regardless of whether or not it's in the registry (with a shallow clone).

@Raynos
Copy link
Collaborator

Raynos commented Aug 14, 2014

👍 I want the hash to be content addressable.

One way to do server side and client side RCSS is to generate a bunch of server side class names from the style object in a deterministic fashion.

Then on the client side you can query the DOM for a list of class names that exist and only append a class name to the DOM for RCSS() calls if it hash does not exist yet.

@chenglou
Copy link
Owner

Cool let's do this then. Can you update the tests though?

@charliermarsh
Copy link
Collaborator Author

@chenglou Tests updated.

chenglou added a commit that referenced this pull request Aug 19, 2014
CSS class names are a function of the style object
@chenglou chenglou merged commit e7a8509 into chenglou:master Aug 19, 2014
@chenglou
Copy link
Owner

Thanks! In the future, we can have our own optimized JSON.stringify, since we know all the recognized style keys.

@charliermarsh charliermarsh deleted the hash-classname branch August 19, 2014 09:40
@charliermarsh
Copy link
Collaborator Author

@chenglou No problem. I'm curious as to whether we can actually do better than JSON.stringify given native browser support... Want to create an issue and we can start trying things out?

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.

Server-side rendering with React triggers a re-render on the client
3 participants