Skip to content

Should 'isset()' take empty arrays into account? #2

@AFoeee

Description

@AFoeee

I wonder whether it would make sense for isset() to take empty arrays into account?

If I correctly understand the application, it is used to check if a widget field is undefined, null or ''.
However, unpopulated media-input-fields with a "multiple" parameter set to true, can return an empty array, right?
(At least I get an empty array, when I delete all existing videos from a 'video-input' field.)

Of course, a user could simply implement something like the following:

// Uses the input of a media field to test whether media was added to it.
function isMediaFieldPopulated(input) {
  return (input && (Array.isArray(input) ? (input.length > 0) : true));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions