Skip to content

Commit 8502374

Browse files
committed
Revert "Fix facebook#1357. Don't append "px" suffix to strings."
This reverts commit 3176377.
1 parent 40fba79 commit 8502374

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

docs/tips/06-style-props-value-px.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,3 @@ Sometimes you _do_ want to keep the CSS properties unitless. Here's a list of pr
4444
- `widows`
4545
- `zIndex`
4646
- `zoom`
47-
48-
Alternatively you can simply pass the unitless value as a string:
49-
50-
```js
51-
var divStyle = {WebkitMagic: "10"}; // rendered as "-webkit-magic:10"
52-
ReactDOM.render(<div style={divStyle}>Hello World!</div>, mountNode);
53-
```

src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ describe('CSSPropertyOperations', function() {
6060
})).toBe('left:0;margin:16px;opacity:0.5;padding:4px;');
6161
});
6262

63-
it('should trim string values', function() {
63+
it('should trim values so `px` will be appended correctly', function() {
6464
expect(CSSPropertyOperations.createMarkupForStyles({
6565
margin: '16 ',
6666
opacity: 0.5,
67-
xmagic: ' 4 ',
68-
})).toBe('margin:16;opacity:0.5;xmagic:4;');
67+
padding: ' 4 ',
68+
})).toBe('margin:16px;opacity:0.5;padding:4px;');
6969
});
7070

7171
it('should not append `px` to styles that might need a number', function() {

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ describe('ReactDOMComponent', function() {
5252
var stubStyle = container.firstChild.style;
5353

5454
// set initial style
55-
var setup = {display: 'block', WebkitMagic: '1', top: 2, fontFamily: 'Arial'};
55+
var setup = {display: 'block', left: '1', top: 2, fontFamily: 'Arial'};
5656
ReactDOM.render(<div style={setup} />, container);
5757
expect(stubStyle.display).toEqual('block');
58-
expect(stubStyle.WebkitMagic).toEqual('1');
58+
expect(stubStyle.left).toEqual('1px');
5959
expect(stubStyle.fontFamily).toEqual('Arial');
6060

6161
// reset the style to their default state

src/renderers/dom/shared/dangerousStyleValue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function dangerousStyleValue(name, value, component) {
7171
}
7272
}
7373
}
74-
return value.trim();
74+
value = value.trim();
7575
}
7676
return value + 'px';
7777
}

0 commit comments

Comments
 (0)