mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Prevent null reference access when unsetting styles
This commit is contained in:
@@ -307,7 +307,7 @@ ReactDOMComponent.Mixin = {
|
||||
// Unset styles on `lastProp` but not on `nextProp`.
|
||||
for (styleName in lastProp) {
|
||||
if (lastProp.hasOwnProperty(styleName) &&
|
||||
!nextProp.hasOwnProperty(styleName)) {
|
||||
(!nextProp || !nextProp.hasOwnProperty(styleName))) {
|
||||
styleUpdates = styleUpdates || {};
|
||||
styleUpdates[styleName] = '';
|
||||
}
|
||||
|
||||
@@ -97,6 +97,11 @@ describe('ReactDOMComponent', function() {
|
||||
expect(stubStyle.display).toEqual('block');
|
||||
expect(stubStyle.fontFamily).toEqual('Helvetica');
|
||||
expect(stubStyle.lineHeight).toEqual('0.5');
|
||||
|
||||
stub.receiveComponent({props: { style: undefined }}, transaction);
|
||||
expect(stubStyle.display).toBe('');
|
||||
expect(stubStyle.fontFamily).toBe('');
|
||||
expect(stubStyle.lineHeight).toBe('');
|
||||
});
|
||||
|
||||
it("should update styles if initially null", function() {
|
||||
|
||||
Reference in New Issue
Block a user