mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Don't set DOM attributes to "undefined" on update
We already skip `null` and `undefined` when building up the stringified html on first render, but if you update a component to the *exact same* conditions, React will leave the DOM in a different state. We shouldn't do that.
This commit is contained in:
committed by
Paul O’Shannessy
parent
74cfc9c274
commit
d1d2d8d463
@@ -71,7 +71,15 @@ var ReactDOMIDOperations = {
|
||||
'updatePropertyByID(...): %s',
|
||||
INVALID_PROPERTY_ERRORS[name]
|
||||
);
|
||||
DOMPropertyOperations.setValueForProperty(node, name, value);
|
||||
|
||||
// If we're updating to null or undefined, we should remove the property
|
||||
// from the DOM node instead of inadvertantly setting to a string. This
|
||||
// brings us in line with the same behavior we have on initial render.
|
||||
if (value != null) {
|
||||
DOMPropertyOperations.setValueForProperty(node, name, value);
|
||||
} else {
|
||||
DOMPropertyOperations.deleteValueForProperty(node, name);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user