-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Ember.isEmpty({}) returns false #5543
Comments
|
Completely misread. Sorry about that. |
@workmanw my usecase isn't null checking. I was passing an object to ...
if (typeof query.procedure !== 'undefined') {
var proc = query.procedure;
var httpRequestType = 'GET';
delete query.procedure;
// check to see if there are additional query params
// Currently Ember.isEmpty(query) will always return false even if query has no additional properties
if (!Ember.isEmpty(query)) {
httpRequestType = 'POST';
}
}
...
|
isEmpty is not meant to check for empty objects:
|
This was decided because we couldn't guarentee the same results across all our browsers. As es3 browsers have no concept of user defined non enumerable methods. At the point in time we where we drop them we could revisit this. |
thanks @stefanpenner will close for now and use @taras suggested method. |
With 2.0 dropping support for IE 8 could we consider fixing this behavior to be true on |
Bump, makes no sense that an empty object isn't empty. |
Confusing. |
We can likely revisit this in 2.0 which drops support for IE8, so now there is a concept of enumerable vs non enumerable properties across all our target platforms. In-fact aspects of ember already rely on this concept. If someone is interested in championing and RFC we may be able to re-open things thought. |
Was this revisited in 2.0? |
I don't think so. And it should have been IMO. It does not make sense that |
Also this is directly present in JQuery – https://api.jquery.com/jQuery.isEmptyObject/ |
Seems silly to dip into jQuery for this check - can we revisit this issue now that we're 3.0? |
Anybody coming across this - looks like in a 2015 rfc, it was decided that returning true for If that is still the current thought process and the addon is a path forward, I would be happy to put that out there. However, it's super simple to implement ourselves, so perhaps that is why nobody has done so ¯_(ツ)_/¯ |
Almost certainly |
We've been using lodash |
I agree. Should I/we put together an RFC? And potentially extracted to an addon as well (for those that gratuitously used them)? |
@snewcomer forge ahead :) emberjs/rfcs#333 |
@rwjblue Getting some feedback that these methods will still be bundled in Ember core. How should we handle the deprecation side of things for these util methods? |
The function name has just been poorly chosen... IsEmpty should tell you yes when given... an empty "set"... |
@jfschaff @marclundgren Old comment, I referenced the description on the jsdoc that didn't mention checking for an empty object. Currently lives here: Not to say that I didn't expect the method to check an empty object as well, just saying that there wasn't such a claim in the first place. (updated original comment) |
Where are we on this? Will this ever be incorporated? |
@ashish2199 the current proposal is to deprecate the APIs, not change them: emberjs/rfcs#334. |
Currently
Ember.isEmpty
returns false if I pass in an empty object when I would expect it to return true. This feels like a gap in the functionality.@taras suggested using
Ember.keys({}).length === 0
and while this certainly works it doesn't feel intuitive when you haveEmber.isEmpty
available.It's trivial to implement - I'd be glad to submit a PR if it's agreed that it is indeed a gap.
The text was updated successfully, but these errors were encountered: