Ensure recursion is terminated on objects with cyclical references

Reviewed By: spicyj

Differential Revision: D2922542

fb-gh-sync-id: 3820569027a5906ff844f1cda5e2e65c2692e235
shipit-source-id: 3820569027a5906ff844f1cda5e2e65c2692e235
This commit is contained in:
Matthew Dapena-Tretter 2016-02-12 14:53:36 -08:00 committed by facebook-github-bot-5
parent 4b722d6d2a
commit bb3d8d5350
2 changed files with 13 additions and 3 deletions

View File

@ -115,7 +115,11 @@ ReactNativeBaseComponent.Mixin = {
this._currentElement = nextElement;
if (__DEV__) {
deepFreezeAndThrowOnMutationInDev(this._currentElement.props);
for (var key in this.viewConfig.validAttributes) {
if (nextElement.props.hasOwnProperty(key)) {
deepFreezeAndThrowOnMutationInDev(nextElement.props[key]);
}
}
}
var updatePayload = ReactNativeAttributePayload.diff(

View File

@ -42,11 +42,17 @@ function deepFreezeAndThrowOnMutationInDev(object: Object) {
if (object.hasOwnProperty(key)) {
object.__defineGetter__(key, identity.bind(null, object[key]));
object.__defineSetter__(key, throwOnImmutableMutation.bind(null, key));
}
}
Object.freeze(object);
Object.seal(object);
for (var key in object) {
if (object.hasOwnProperty(key)) {
deepFreezeAndThrowOnMutationInDev(object[key]);
}
}
Object.freeze(object);
Object.seal(object);
}
}