Skip to content

Fixed bug with styled-system to prevent undefined properties (issue #94) #102

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

Closed
wants to merge 2 commits into from

Conversation

carldufourm
Copy link

This pull request is to fix issue #94

Describe the bug
When using vue-styled-components with styled-system version 5+ and you add styled-system utilities (space for example), you can see that in the CSS of the element you'll have every property of space with a value of undefined. I tested with the latest version 4 (4.2.4) of styled-system and there is no bug.

To Reproduce

  • Start a Vue project with packages "vue-styled-components" & "styled-system" (version 5+, this is important)
  • Create a styled component with prop types defined
  • Put that styled component in a view
  • Witness that all of it's prop types are in the CSS with undefined value

With styled-system version 4, no bug
https://codesandbox.io/s/vue-styledsystem-gl9z8

With styled-system version 5, with the bug
https://codesandbox.io/s/vue-styled-system-v3r91

Expected behavior
Since in Vue we need to define all prop types, the css ends up with lots of undefined values. There should be no undefined properties when these properties have no value. When a property has a value, it should end up with the correct value in the style - this part currently works.

Screenshots
Here you can see the undefined properties
Screen Shot 2019-10-25 at 8 47 54 AM

@liqueflies
Copy link
Collaborator

I understand what's happened it's just strange for me that we need to check this inside that method function and not before. It check also only for undefined and not for null results.

@carldufourm
Copy link
Author

Yeah I see what you mean. I could add the null check.
I'm not very familiar with the code, could you point me to where it could be checked before?
Thanks a lot.

andreruffert added a commit to andreruffert/vue-styled-components that referenced this pull request Jun 26, 2020
Prevents generating `undefined` style properties e.g

`{ fontSize: '16px', fontFamily: undefined }`

The above props would generate the following styles:

```
font-size: 16px;
font-family: undefined;
```

The new feature is filtering false props before generating and injecting the styles. The new styles now look something like this:

```
font-size: 16px;
```

More details: styled-components#102
andreruffert added a commit to andreruffert/vue-styled-components that referenced this pull request Jul 6, 2020
Prevents generating `undefined` style properties e.g

`{ fontSize: '16px', fontFamily: undefined }`

The above props would generate the following styles:

```
font-size: 16px;
font-family: undefined;
```

The new feature is filtering false props before generating and injecting the styles. The new styles now look something like this:

```
font-size: 16px;
```

More details: styled-components#102
andreruffert added a commit to andreruffert/vue-styled-components that referenced this pull request Jul 30, 2020
Prevents generating `undefined` style properties e.g

`{ fontSize: '16px', fontFamily: undefined }`

The above props would generate the following styles:

```
font-size: 16px;
font-family: undefined;
```

The new feature is filtering false props before generating and injecting the styles. The new styles now look something like this:

```
font-size: 16px;
```

More details: styled-components#102
liqueflies added a commit that referenced this pull request Nov 28, 2020
@liqueflies
Copy link
Collaborator

Solved merging #111

@liqueflies liqueflies closed this Nov 28, 2020
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

Successfully merging this pull request may close these issues.

2 participants