-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Nested Lists] ListType: reset list when no value is submitted, cast objects with nu… #3776
base: nested-lists
Are you sure you want to change the base?
Conversation
…meric keys to array
// Reset the value when null or an empty string is provided | ||
if (values === null || values === '') { | ||
// Reset the value when no value or null or an empty string is provided | ||
if (values === undefined || values === null || values === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a definite change in semantics, I think it would be better to leave the undefined
case as-is…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was cheating here to fix two bugs at once.
With the undefined
case as it is there is no way to empty out the list. The last item will never be deleted because an empty list won't be submitted at all. TextArray, DateArray, and NumberArray all treat undefined the way I've done here.
if (!Array.isArray(values)) { | ||
values = [values]; | ||
if (typeof values === 'object' && values[0] !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should use hasOwnProperty
in this instance, although for this particular use case, I suppose array values should always be at least null
? Not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, hasOwnProperty
is probably more correct. Thanks!
…0' as own property
Description of changes
multer
that causes submitted arrays of 22 items or more to be parsed as objects instead of arrays.Related issues (if any)
Testing
npm run test-all
ran successfully.…meric keys to array