-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[cache] Add ignore flag for the unreliable selectors warning #1209
Conversation
Codecov Report
|
Codecov Report
|
I'm not completely opposed to doing something like this but the way this works specifically would require us to also remove the property in production and I'm really against adding code in prod that isn't necessary in prod. |
@mitchellhamilton @kylegach I'd suggest that we simply change it to use a CSS custom property, e.g. |
Preview Docs Built with commit 2920fc4 |
@mitchellhamilton — Glad to hear you're open to the idea. I updated the code (force-pushed) and the PR description to reflect @brentertz's suggestion above. |
44437dc
to
06437b0
Compare
Changing it to a custom property doesn't really solve the problem. There's nothing that will break with shipping an invalid css property to production and it's better than a custom property in a way since browsers will ignore the invalid property. The bigger problem is that an extra css property is there at all. I think it's possible to do with comments like this and since comments are already removed, it won't have any ramifications on production. css`
&:first-child /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
}
`;
css({
"&:first-child /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */": {}
}); Yes, I know it's long, that's intentional, it should be difficult for people to disable the warning. It's there to help people and fix a problem they could have so it should be be difficult to stop the warning because in most cases, people should fix their code. |
d80aa0e
to
648d573
Compare
Oh! Thanks for the suggestion to place the comment in the selector. I had tried comments first, but couldn't figure out how to make it work for style objects. Agreed that it's a good idea to have an obnoxiously verbose flag. Just updated the PR description and force-pushed again. Beyond changing the flag to a comment, the major changes from last review are no longer printing the compiled selector in the error (decided it wasn't that helpful) and a bunch more test cases for compound selectors, which necessitated re-organizing that section of the spec a bit. |
Did this flag make it in? I'm using version 10.0.7 with the disable flag in my styles, but I'm still seeing the warning. |
Any updates on this getting merged? |
I'd like to see this change too. |
Force-pushed one more time with the changes requested and updated the description accordingly. Should be good to go! Thanks for the guidance, @mitchellhamilton. |
What:
/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */
after the pseudo classWhy:
The inability to disable or ignore these warnings is an issue for some (#1105). Until a decision is made on #1178, it is likely worthwhile to provide a way to ignore them. This seemed like a lightweight way of doing so, that is nicely co-located with the existing warning logic.
How:
Modified the implementation of the stylis plugin used for the warning to check for the presence of the flag.
Checklist: