Skip to content

Prevents adding units to css custom properties - #9966

Merged
gaearon merged 6 commits into
react:masterfrom
TrySound:unitless-css-custom-properties
Jun 14, 2017
Merged

Prevents adding units to css custom properties#9966
gaearon merged 6 commits into
react:masterfrom
TrySound:unitless-css-custom-properties

Conversation

@TrySound

Copy link
Copy Markdown
Contributor

Ref #9963

@TrySound

Copy link
Copy Markdown
ContributorAuthor

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

@aweary

Copy link
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

@aweary whitespaces are not significant in css syntaxically. Both defintioins are equivalent. Just a code style.

--foo: value;
--foo: value ;

gaearon
gaearon previously requested changes Jun 14, 2017
}

if (
name.indexOf('--') !== 0 &&

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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

Copy link
Copy Markdown
Collaborator

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

@gaearon

Copy link
Copy Markdown
Collaborator

(Never mind, just did that.)

if (!styles.hasOwnProperty(styleName)) {
continue;
}
var isComputedProperty = styleName.indexOf('--') === 0;

Copy link
Copy Markdown
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.

@gaearongaearon left a comment

Copy link
Copy Markdown
Collaborator

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 react:masterJun 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
@gaearongaearon mentioned this pull request Jun 15, 2017
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
* 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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@TrySound@aweary@gaearon@facebook-github-bot