question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix leaking CSS variables

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pgmanutdcommented, Oct 31, 2020

Actually I thought you will do on Monday and I should not do it 😛. But then we discussed and did today hehehehe.

1reaction
pgmanutdcommented, Oct 31, 2020

Yeah, sorry about that 🙏 thanks for filling it in On Fri, 30 Oct 2020, 7:06 pm Prashant Goel, @.***> wrote: I’ll fill in details later just made this so I don’t forget about it 😂 Did you make watermelon update?? 😁 Hehehe no worries. Yups I did. You didn’t tell me to do though 😞 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#333 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT4PHNHO4OI6DDNW2M7NFDSNJX2FANCNFSM4TELJWNA .

No worries mate ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

150728 – leaks seen in fast/css/variables tests - WebKit Bugzilla
SUMMARY CSSParserValueList leaks seen in fast/css/variables tests. * STEPS TO REPRODUCE shell> run-webkit-tests --leaks -1 ...
Read more >
Utilizing CSS variables caused a browser behavior that leaks ...
Using the CSS variables will cause the browser to request the background image twice. If there are multiple links like this, each one...
Read more >
[css-variables] Custom properties are slow when setting them ...
[css-variables] Clone style when there are no variable references. When resolving the CSS Custom Properties inheritance, we recalculate all
Read more >
postcss-css-variables | Yarn - Package Manager
PostCSS plugin to transform CSS Custom Properties (CSS variables) syntax into a static representation. This plugin provides a future-proof way of using most ......
Read more >
4 Types of Memory Leaks in JavaScript and How to Get Rid Of ...
In the context of JavaScript, unwanted references are variables kept ... However, leaks that are periodic are bugs and must be fixed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found