Skip to content

Commit

Permalink
[BUGFIX beta] Fix a recent regression which resulted in `Ember.A(null…
Browse files Browse the repository at this point in the history
…)` returning `null` instead of an array. See issue #13284.
  • Loading branch information
Wesley Workman committed Apr 9, 2016
1 parent 6498702 commit 4dea78c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ember-runtime/lib/system/native_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ 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 || []; };
} else {
A = function (arr = []) {
A = function (arr) {
if (!arr) { arr = []; }
return EmberArray.detect(arr) ? arr : NativeArray.apply(arr);
};
}
Expand Down
12 changes: 12 additions & 0 deletions packages/ember-runtime/tests/system/native_array/a_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import EmberArray from 'ember-runtime/mixins/array';
import { A } from 'ember-runtime/system/native_array';

QUnit.module('Ember.A');

QUnit.test('Ember.A', function() {
deepEqual(A([1, 2]), [1, 2], 'array values were not be modified');
deepEqual(A(), [], 'returned an array with no arguments');
deepEqual(A(null), [], 'returned an array with a null argument');
ok(EmberArray.detect(A()), 'returned an ember array');
ok(EmberArray.detect(A([1, 2])), 'returned an ember array');
});

0 comments on commit 4dea78c

Please sign in to comment.