Skip to content
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] Allow ArrayProxy#pushObjects to accept ArrayProxy again #16853

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/ember-runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
},
Expand Down
2 changes: 2 additions & 0 deletions packages/ember-runtime/lib/system/array_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}

Expand Down