Skip to content

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 ;

}

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

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.)

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.

4 participants