Error when the parent property of a child property is a null
pyrostrex opened this issue · comments
Example data:
{
fields: {
propertyA: null
}
}
Example html used:
<input v-model="model['propertyA.childPropertyA']" />
Example of computed (same as example):
model: {
return this.$deepModel(this.fields);
}
Error:
Error in render function: "TypeError: Cannot convert undefined or null to object"
Expected json output:
{
fields: {
propertyA: {}
}
}
Thank you for this wonderful library.
I will look into this as soon as I can. Thanks!
This has been resolved with a null check in the vueSet
method. See source
Original
vue-deepset/src/vue-deepset.js
Line 20 in 940d0c9
Updated
vue-deepset/src/vue-deepset.js
Lines 20 to 22 in 1360559
v0.5.2 has been published to npm with the fix.
Additionally setting the property to undefined
instead of null
would have probably worked in the previous version. The current fix could cause issue if the developer tries set a higher path to null
and another piece of code tries to set a lower path, the lower path will always win. This is probably the most desired behavior which is why I went ahead and published this change.