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:
Paul O'Shannessy
2013-07-22 10:28:21 -07:00
committed by Paul O’Shannessy
parent 74cfc9c274
commit d1d2d8d463
+9 -1
View File
@@ -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);
}
},
/**