-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Prevents adding units to css custom properties #9966
Prevents adding units to css custom properties #9966
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 ; |
@@ -42,6 +42,7 @@ function dangerousStyleValue(name, value, component) { | |||
} | |||
|
|||
if ( | |||
name.indexOf('--') !== 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
var styleValue = dangerousStyleValue( | ||
styleName, | ||
styles[styleName], | ||
component, | ||
isCustomProperty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.) |
@@ -199,13 +199,19 @@ var CSSPropertyOperations = { | |||
if (!styles.hasOwnProperty(styleName)) { | |||
continue; | |||
} | |||
var isComputedProperty = styleName.indexOf('--') === 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably mean isCustomProperty
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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