You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems counter-intuitive that Ember.isEmpty({}) returns false. Should it return true instead?
One theoretical hurdle I ran into while writing up the change locally was justifying that the methods which depend on isEmpty should also change. Those methods are isBlank and isPresent.
isBlank is fairly reasonable to justify: an empty object is also blank. Pretty straight-forward.
isPresent is not as easy. If Ember.isEmpty({}) returns true, then Ember.isPresent({}) returns false. This means an empty object is "not present". This seems a little strange at first. I discussed this with a colleague, and we settled on this rational:
An array is an object.
An empty array is both blank and "not present".
Therefore, an empty object is also blank and "not present".
Previous discussion indicated that this was because of support for ES3 browsers. Now that Ember 2.0 is dropping support for IE8 then this should be possible.
Although I agree this would be nice I think this should be user land or addon concern. What defines an empty object is tricky (although I'm sure consensus can be reached) but changes to these core methods would provide dubious value as existing apps do depend on the current semantics.
I suspect if we where to write isEmpty today it would include a reasonable semantic for this
What about making an addon to "opt-in", then make the switch at 3.0? Then add a depreciation (sigh) about installing the addon to silence the depreciation, when the developer ensures their code will handle the change properly.
@Panman8201 i don't think making the change is worth-while, isEmpty has semantics, changing them is a-bit of a trap. An addon providing some variation of it, sounds like the best path.
Activity
rlivsey commentedon Aug 12, 2015
Previous discussion indicated that this was because of support for ES3 browsers. Now that Ember 2.0 is dropping support for IE8 then this should be possible.
mmun commentedon Aug 13, 2015
Any changes these functions will likely break a lot of apps :( It would require mass consensus to change.
stefanpenner commentedon Aug 13, 2015
Although I agree this would be nice I think this should be user land or addon concern. What defines an empty object is tricky (although I'm sure consensus can be reached) but changes to these core methods would provide dubious value as existing apps do depend on the current semantics.
I suspect if we where to write isEmpty today it would include a reasonable semantic for this
mmun commentedon Aug 13, 2015
An addon is a good solution.
Panman82 commentedon Sep 14, 2015
What about making an addon to "opt-in", then make the switch at 3.0? Then add a depreciation (sigh) about installing the addon to silence the depreciation, when the developer ensures their code will handle the change properly.
stefanpenner commentedon Sep 14, 2015
@Panman8201 i don't think making the change is worth-while, isEmpty has semantics, changing them is a-bit of a trap. An addon providing some variation of it, sounds like the best path.
Going to close this as working as intended.
benoror commentedon Nov 18, 2016
Just created a hbs helper for this particular use-case: https://gist.github.com/benoror/d9a3fb6f4892897af390bcb9d8cbeddf