diff --git a/packages/ember-runtime/lib/mixins/array.js b/packages/ember-runtime/lib/mixins/array.js index 1482bfbec9a..4c96d33c2fa 100644 --- a/packages/ember-runtime/lib/mixins/array.js +++ b/packages/ember-runtime/lib/mixins/array.js @@ -1194,6 +1194,8 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { You should replace amt objects started at idx with the objects in the passed array. You should also call `this.arrayContentDidChange()` + Note that this method is expected to validate the type(s) of objects that it expects. + @method replace @param {Number} idx Starting index in the array to replace. If idx >= length, then append to the end of the array. @@ -1318,9 +1320,6 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @public */ pushObjects(objects) { - if (!Array.isArray(objects)) { - throw new TypeError('Must pass Enumerable to MutableArray#pushObjects'); - } this.replace(this.length, 0, objects); return this; }, diff --git a/packages/ember-runtime/lib/system/array_proxy.js b/packages/ember-runtime/lib/system/array_proxy.js index 16e8c4b9da6..f0056d7f1cb 100644 --- a/packages/ember-runtime/lib/system/array_proxy.js +++ b/packages/ember-runtime/lib/system/array_proxy.js @@ -133,6 +133,8 @@ export default class ArrayProxy extends EmberObject { return objectAt(get(this, 'arrangedContent'), idx); } + // See additional docs for `replace` from `MutableArray`: + // https://www.emberjs.com/api/ember/3.3/classes/MutableArray/methods/replace?anchor=replace replace(idx, amt, objects) { assert( 'Mutating an arranged ArrayProxy is not allowed', diff --git a/packages/ember-runtime/tests/mutable-array/pushObjects-test.js b/packages/ember-runtime/tests/mutable-array/pushObjects-test.js index a89d3f97571..55a67b4139e 100644 --- a/packages/ember-runtime/tests/mutable-array/pushObjects-test.js +++ b/packages/ember-runtime/tests/mutable-array/pushObjects-test.js @@ -5,7 +5,7 @@ class PushObjectsTests extends AbstractTestCase { '@test should raise exception if not Ember.Enumerable is passed to pushObjects'() { let obj = this.newObject([]); - this.assert.throws(() => obj.pushObjects('string')); + expectAssertion(() => obj.pushObjects('string')); } }