Skip to content

Commit

Permalink
Add scale as a unitless property (#25601)
Browse files Browse the repository at this point in the history
## Summary

CSS has a new property called `scale` (`scale: 2` is a shorthand for
`transform: scale(2)`).

In vanilla JavaScript, we can do the following:

```js
document.querySelector('div').scale = 2;
```

which will make the `<div>` twice as big. So in JavaScript, it is
possible to pass a plain number.
However, in React, the following does not work currently:


```js
<div style={{scale: 2}}>
```

because `scale` is not in the list of unitless properties. This PR adds
`scale` to the list.


## How did you test this change?

I built `react` and `react-dom` from source and copied it into the
node_modules of my project and verified that now `<div style={{scale:
2}}>` does indeed work whereas before it did not.
  • Loading branch information
JonnyBurger authored Feb 16, 2023
1 parent 2f40170 commit fbf3bc3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-dom-bindings/src/shared/CSSProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const isUnitlessNumber = {
opacity: true,
order: true,
orphans: true,
scale: true,
tabSize: true,
widows: true,
zIndex: true,
Expand Down

0 comments on commit fbf3bc3

Please sign in to comment.