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

Prevents adding units to css custom properties #9966

Merged
merged 6 commits into from Jun 14, 2017
Merged

Prevents adding units to css custom properties #9966

merged 6 commits into from Jun 14, 2017

Conversation

TrySound
Copy link
Contributor

Ref #9963

@TrySound
Copy link
Contributor Author

There's a problem with jsdom api. I used browser non-compatible api.

@aweary
Copy link
Contributor

aweary commented Jun 14, 2017

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?

@TrySound
Copy link
Contributor Author

@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 &&
Copy link
Collaborator

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?

Copy link
Contributor Author

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,
Copy link
Collaborator

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?

@gaearon gaearon dismissed their stale review June 14, 2017 21:13

outdated

@gaearon
Copy link
Collaborator

gaearon commented Jun 14, 2017

Looks good! You need to run ./scripts/fiber/record-tests and commit the result for CI to pass.

@gaearon
Copy link
Collaborator

gaearon commented Jun 14, 2017

(Never mind, just did that.)

@@ -199,13 +199,19 @@ var CSSPropertyOperations = {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
var isComputedProperty = styleName.indexOf('--') === 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably mean isCustomProperty.

Copy link
Collaborator

@gaearon gaearon left a 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.

@gaearon gaearon merged commit 29eb21d into facebook:master Jun 14, 2017
gaearon pushed a commit that referenced this pull request Jun 14, 2017
* 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
gaearon pushed a commit that referenced this pull request Jun 14, 2017
* 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
@TrySound TrySound deleted the unitless-css-custom-properties branch June 14, 2017 22:40
gaearon pushed a commit that referenced this pull request Jun 14, 2017
* 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
@gaearon gaearon mentioned this pull request Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants