atlassian-labs / compiled

A familiar and performant compile time CSS-in-JS library for React.
https://compiledcssinjs.com
Apache License 2.0
1.98k stars 68 forks source link

Properties fall-through to wrapped DOM element when there are default values in the property declaration #1629

Closed yamadapc closed 6 months ago

yamadapc commented 7 months ago

Describe the bug

If a component is declared as

const Box = styled.div({
  marginTop: ({ marginTop }) => marginTop,
});

When used it ends-up having a --variable-for-margin-top: ... value set to the property value, assuming it is used like <Box marginTop={...} />.

When the property parameters object destructuring expression has a property default however, such as:

const Box = styled.div({
  marginTop: ({ marginTop = 0 }) => marginTop,
});

When used it ends-up having a --variable-for-margin-top: ... value set to the property value, but also having the margintop=... attribute set on the DOM element. This leads to react warnings on unexpected attribute values.