Make ReactDOMComponent-test pass with useCreateElement
Ben Alpert committed
Oct 15, 2015 at 16:00 UTC
276ef737fee6613417342283577f250af6aa1a29
3 files changed
+17
-6
src/renderers/dom/shared/CSSPropertyOperations.js
+8
-3
@@ -140,7 +140,8 @@ var CSSPropertyOperations = {
140
}
141
if (styleValue != null) {
142
serialized += processStyleName(styleName) + ':';
143
- serialized += dangerousStyleValue(styleName, styleValue, component) + ';';
143
+ serialized +=
144
+ dangerousStyleValue(styleName, styleValue, component) + ';';
145
}
146
}
147
return serialized || null;
@@ -153,7 +154,7 @@ var CSSPropertyOperations = {
154
* @param {DOMElement} node
155
* @param {object} styles
156
*/
156
- setValueForStyles: function(node, styles) {
157
+ setValueForStyles: function(node, styles, component) {
158
var style = node.style;
159
for (var styleName in styles) {
160
if (!styles.hasOwnProperty(styleName)) {
@@ -162,7 +163,11 @@ var CSSPropertyOperations = {
163
if (__DEV__) {
164
warnValidStyle(styleName, styles[styleName]);
165
}
165
- var styleValue = dangerousStyleValue(styleName, styles[styleName]);
166
+ var styleValue = dangerousStyleValue(
167
+ styleName,
168
+ styles[styleName],
169
+ component
170
+ );
171
if (styleName === 'float') {
172
styleName = styleFloatAccessor;
173
}
src/renderers/dom/shared/ReactDOMComponent.js
+5
-1
@@ -1041,7 +1041,11 @@ ReactDOMComponent.Mixin = {
1041
}
1042
}
1043
if (styleUpdates) {
1044
- CSSPropertyOperations.setValueForStyles(getNode(this), styleUpdates);
1044
+ CSSPropertyOperations.setValueForStyles(
1045
+ getNode(this),
1046
+ styleUpdates,
1047
+ this
1048
+ );
1049
}
1050
},
1051
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+4
-2
@@ -51,7 +51,7 @@ describe('ReactDOMComponent', function() {
51
var stubStyle = container.firstChild.style;
52
53
// set initial style
54
- var setup = {display: 'block', left: '1', top: 2, fontFamily: 'Arial'};
54
+ var setup = {display: 'block', left: '1px', top: 2, fontFamily: 'Arial'};
55
ReactDOM.render(<div style={setup} />, container);
56
expect(stubStyle.display).toEqual('block');
57
expect(stubStyle.left).toEqual('1px');
@@ -152,7 +152,9 @@ describe('ReactDOMComponent', function() {
152
var div = document.createElement('div');
153
var One = React.createClass({
154
render: function() {
155
- return this.props.inline ? <span style={{fontSize: '1'}} /> : <div style={{fontSize: '1'}} />;
155
+ return this.props.inline ?
156
+ <span style={{fontSize: '1'}} /> :
157
+ <div style={{fontSize: '1'}} />;
158
},
159
});
160
var Two = React.createClass({