-
-
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
[BUGFIX beta] Fix a recent regression with Ember.A
#13287
Conversation
} else { | ||
A = function (arr = []) { | ||
if (arr === null) { arr = []; } |
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.
In the native version, you rely on truthiness as a check for arr
, but in this version you look explicitly for null
instead of !arr
. Is there a reason for the difference?
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.
@mixonic Yea that's a good point. I think I was just trying to be more explicit about what was happening. Someone reading the following might feel that it's redundant:
A = function (arr = []) {
if (!arr) { arr = []; }
return EmberArray.detect(arr) ? arr : NativeArray.apply(arr);
};
But it's definitely inconsistent between the two. So let's fix this, which do you think is prefered?
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.
Dunno- I would defer to the old behavior since this is a regression fix. Can you perhaps try it out on 2.4 or and older version and simply match that? Thanks man.
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.
@mixonic Ha. It turns out the old behavior was inconsistent too. 586d4c6#diff-7. I think I'll just use the truthiness check and add a code comment. Then see what others think.
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.
😭 truthiness was the mode with prototype extensions enabled (which is the most common), so I agree normalizing around that as a BUGFIX makes sense 👍
@@ -138,9 +138,11 @@ var A; | |||
|
|||
if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Array) { | |||
NativeArray.apply(Array.prototype); | |||
A = function (arr = []) { return arr; }; | |||
A = function (arr = []) { return arr || []; }; |
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.
why bother then with the default arg?
the default arg is redundant to handling an explicitly undefined or null, please remove. |
also, the comment is unneeded with the regression test. |
This regression is unreleased? |
…)` returning `null` instead of an array. See issue emberjs#13284.
Chatted with @krisselden briefly on Slack. We agreed that keeping the default args was unnecessary in this case. As a result of that I removed the code comment as well. This affects beta, it does not affect any release. |
Ember.A
Ember.A
Thanks @workmanw |
Anytime! 😄 |
Due to a recent regression,
Ember.A(null)
would returnnull
instead of[]
. See issue #13284.