Prevent null reference access when unsetting styles

This commit is contained in:
Daniel Gasienica
2014-06-10 13:33:32 -07:00
parent 2f61996ec3
commit 7c2dec5bd3
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -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() {