Skip to content
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

[BUGFIX] isEmpty on nested objects #18882

Closed
wants to merge 1 commit into from
Closed

[BUGFIX] isEmpty on nested objects #18882

wants to merge 1 commit into from

Conversation

locks
Copy link
Contributor

@locks locks commented Apr 18, 2020

Because of a re-structuring, it was too much work rebasing or even cherry-picking #16879 (over 300 git conflicts ;_;) so I reimplemented the fix, sorry @janvotava.

Fixes #16879.
Fixes #16878.

@locks locks requested a review from rwjblue April 18, 2020 16:41
if (objectType === 'object') {
let length = get(obj, 'length');
if (typeof length === 'number') {
return !length;
}
}

if (typeof obj.length === 'number' && objectType !== 'function') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwjblue you had a comment about this check, but removing it made tests fail so I didn't touch it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't grok how this can ever be hit. The check just above here is checking all "object"s that have a numeric length property.

Copy link
Contributor

@lifeart lifeart Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwjblue it has different objectType (object vs function), chack above true only for objectType === 'object' object type, and @locks chech is for objectType !== 'function'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it's true for string case typeof 'foo'.length === 'number' && typeof 'foo' !== 'function'

@locks locks force-pushed the is-empty-nested branch from fbf0f7a to 3a68e59 Compare April 19, 2020 10:41
@locks locks closed this Nov 18, 2020
@locks locks deleted the is-empty-nested branch November 18, 2020 13:57
@locks locks restored the is-empty-nested branch February 11, 2022 19:46
@locks locks deleted the is-empty-nested branch February 11, 2022 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants