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

Fix leaking CSS variables #333

Closed
itsdouges opened this issue Oct 29, 2020 · 7 comments · Fixed by #423
Closed

Fix leaking CSS variables #333

itsdouges opened this issue Oct 29, 2020 · 7 comments · Fixed by #423
Labels
bug 🐛 Something isn't working

Comments

@itsdouges
Copy link
Collaborator

itsdouges commented Oct 29, 2020

Describe the bug
Non-inherited CSS properties are being inherited thanks to the shared CSS variable declaration (they have the same name).

This is OK behaviour for properties that inherit - not ok for ones that shouldn't.

To Reproduce
Steps to reproduce the behavior:

import React from 'react';
import { styled } from '@compiled/core';

const Box = styled.div<{ border?: string }>`
  border: ${(props) => props.border || ''};
`;

export const NestedWithDynamicValues = () => (
  <Box border="2px solid red">
    Should have border
    <Box>Should not have border</Box>
  </Box>
);

Expected behavior

Nested Box should not have a border.

Additional context

We can fix this by unsetting the CSS variable when it resolves to undefined.

--value: ;

Currently we resolve to an empty string if it has a prefix/suffix - to fix this we will probably have to always do it for everything.

Testing notes

  • Css prop interpolations
  • Styled component interpolations
@pgmanutd
Copy link
Contributor

pgmanutd commented Oct 30, 2020

🤔 What is this about?

Edit: Is it variables we create for classes 🤔?

@itsdouges

This comment has been minimized.

@pgmanutd

This comment has been minimized.

@itsdouges

This comment has been minimized.

@pgmanutd

This comment has been minimized.

@pgmanutd

This comment has been minimized.

@itsdouges
Copy link
Collaborator Author

itsdouges commented Dec 22, 2020

Blocked by facebook/react#20497

Edit: Unblocked!

@itsdouges itsdouges removed the blocked 🚫 This can't be completed because of something else label Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants