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

Inline style with 0 value doesn't add "px" #2721

Closed
DjebbZ opened this issue Dec 16, 2014 · 3 comments
Closed

Inline style with 0 value doesn't add "px" #2721

DjebbZ opened this issue Dec 16, 2014 · 3 comments

Comments

@DjebbZ
Copy link

DjebbZ commented Dec 16, 2014

Hello,

The docs say :

When specifying a pixel value for your inline style prop, React automatically appends the string "px" for you after your number value.

But not for 0 (the number). On purpose ?

@waldreiter
Copy link
Contributor

It's a bit weird, but I guess it is on purpose.

MDN has this: The length unit is optional after the 0.

In the react code the 'px' is not added if value === 0, see here: https://github.com/facebook/react/blob/master/src/browser/ui/dom/dangerousStyleValue.js#L45-48

It's weird because the string '0'gets expanded to '0px'. More discussion is in #1357.

@DjebbZ
Copy link
Author

DjebbZ commented Dec 16, 2014

Thx for the answer. I think I can close, I have the answer for the "why".

@DjebbZ DjebbZ closed this as completed Dec 16, 2014
@DjebbZ
Copy link
Author

DjebbZ commented Dec 16, 2014

Maybe updating the docs ?

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

No branches or pull requests

2 participants