mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #3410 from robertknight/3409-style-null-to-nonnull
Fix incorrect update of style when props.style transitions from null to non-null
This commit is contained in:
@@ -367,6 +367,7 @@ ReactDOMComponent.Mixin = {
|
||||
styleUpdates[styleName] = '';
|
||||
}
|
||||
}
|
||||
this._previousStyleCopy = null;
|
||||
} else if (registrationNameModules.hasOwnProperty(propKey)) {
|
||||
if (lastProps[propKey]) {
|
||||
// Only call deleteListener if there was a listener previously or
|
||||
|
||||
@@ -152,6 +152,17 @@ describe('ReactDOMComponent', function() {
|
||||
expect(stubStyle.color).toEqual('');
|
||||
});
|
||||
|
||||
it("should update styles when 'style' changes from null to object", function() {
|
||||
var container = document.createElement('div');
|
||||
var styles = {color: 'red'};
|
||||
React.render(<div style={styles} />, container);
|
||||
React.render(<div />, container);
|
||||
React.render(<div style={styles} />, container);
|
||||
|
||||
var stubStyle = container.firstChild.style;
|
||||
expect(stubStyle.color).toEqual('red');
|
||||
});
|
||||
|
||||
it("should empty element when removing innerHTML", function() {
|
||||
var container = document.createElement('div');
|
||||
React.render(<div dangerouslySetInnerHTML={{__html: ':)'}} />, container);
|
||||
|
||||
Reference in New Issue
Block a user