Prevents adding units to css custom properties#9966
Prevents adding units to css custom properties#9966gaearon merged 6 commits intofacebook:masterfrom TrySound:unitless-css-custom-properties
Conversation
|
There's a problem with jsdom api. I used browser non-compatible api. |
|
What does the CSS custom properties spec say about leading/trailing whitespace? We're still trimming the stringified value, should we avoid doing that for custom properties? |
|
@aweary whitespaces are not significant in css syntaxically. Both defintioins are equivalent. Just a code style. --foo: value;
--foo: value ; |
| } | ||
|
|
||
| if ( | ||
| name.indexOf('--') !== 0 && |
There was a problem hiding this comment.
It seems unfortunate to do this check here since we also check in the code path that calls this function. So it will get called twice for each property.
Can you please keep a single check in setValueForStyles (and any other methods calling dangerousStyleValue), and instead add a boolean isCustomProperty to dangerousStyleValue?
| styleName, | ||
| styles[styleName], | ||
| component, | ||
| isCustomProperty, |
There was a problem hiding this comment.
This is not the only place this function is called as far as I can see. Can you please make sure this argument always exists?
|
Looks good! You need to run |
|
(Never mind, just did that.) |
| if (!styles.hasOwnProperty(styleName)) { | ||
| continue; | ||
| } | ||
| var isComputedProperty = styleName.indexOf('--') === 0; |
There was a problem hiding this comment.
You probably mean isCustomProperty.
gaearon
left a comment
There was a problem hiding this comment.
I made a few minor fixes, should be good to merge if CI passes.
* Prevents adding units to css custom properties * Fix code style * Optimize custom property checking * Prevents adding units to css custom properties in markup creation * Update passing tests * Fix argument name and reuse check in DEV
* Prevents adding units to css custom properties * Fix code style * Optimize custom property checking * Prevents adding units to css custom properties in markup creation * Update passing tests * Fix argument name and reuse check in DEV
* Prevents adding units to css custom properties * Fix code style * Optimize custom property checking * Prevents adding units to css custom properties in markup creation * Update passing tests * Fix argument name and reuse check in DEV
Ref #9963