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

Using Aphrodite in react-storybook renders empty styles declaration #321

Closed
lifeiscontent opened this issue Apr 24, 2018 · 4 comments
Closed

Comments

@lifeiscontent
Copy link

For some reason the style that Aphrodite generates doesn't get populated for me when using react-storybook.

Also, I tried adding a :before selector and that doesn't seem to be working in react-storybook either.

Any guidance here would be greatly appreciated, thanks!

@majapw
Copy link
Contributor

majapw commented Jun 12, 2018

I am also seeing this empty <style> tag in both a storybook and a non-storybook environment.

The styles are still getting applied, but inspecting in Chrome, FF, and even downloading the page as an HTML file does not give me what must be the real contents of the style tag.
screen shot 2018-06-12 at 1 38 50 pm

I imagine this has something to do with the Aphrodite 2.0 upgrade.

@majapw
Copy link
Contributor

majapw commented Jun 12, 2018

Okay so taking a deeper dive into this issue, this appears to be due to https://github.com/Khan/aphrodite/blob/master/src/inject.js#L46-L58.

Basically, in modern browsers that support it, Aphrodite is using insertRule on the CSSStyleSheet object attached to the style tag. insertRule notably does not affect the DOM (which is probably part of the reason why it's more performance) but rather attaches CSS rules as metadata to the style tag.

@lifeiscontent if you look at the console, and do document.querySelector('[data-aphrodite]').cssRules.rules, you should be able to take a look at all the style definitions that are being inserted into the page.

@kevinbarabash
Copy link
Contributor

@lifeiscontent can you post a link to an example of this?

@lifeiscontent
Copy link
Author

@kevinbarabash issue is too old, I don't even remember which project I was working in. 🗡

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

No branches or pull requests

3 participants