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

mixins/array: Remove deprecated code #17394

Merged
merged 2 commits into from
Dec 20, 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
57 changes: 1 addition & 56 deletions packages/@ember/-internals/runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/**
@module @ember/array
*/
import { ARRAY_AT_EACH } from '@ember/deprecated-features';
import { DEBUG } from '@glimmer/env';
import { PROXY_CONTENT } from '@ember/-internals/metal';
import { symbol, toString, HAS_NATIVE_PROXY, tryInvoke } from '@ember/-internals/utils';
import { symbol, HAS_NATIVE_PROXY, tryInvoke } from '@ember/-internals/utils';
import {
get,
set,
Expand All @@ -15,7 +14,6 @@ import {
aliasMethod,
Mixin,
hasListeners,
eachProxyFor,
beginPropertyChanges,
endPropertyChanges,
addArrayObserver,
Expand All @@ -28,7 +26,6 @@ import Enumerable from './enumerable';
import compare from '../compare';
import { ENV } from '@ember/-internals/environment';
import Observable from '../mixins/observable';
import copy from '../copy';
import MutableEnumerable from './mutable_enumerable';
import { typeOf } from '../type-of';

Expand Down Expand Up @@ -1137,45 +1134,6 @@ const ArrayMixin = Mixin.create(Enumerable, {
let predicate = value === value ? item => item !== value : item => item === item;
return this.filter(predicate);
},

/**
Returns a special object that can be used to observe individual properties
on the array. Just get an equivalent property on this object and it will
return an array that maps automatically to the named key on the
member objects.

`@each` should only be used in a non-terminal context. Example:

```javascript
myMethod: computed('posts.@each.author', function(){
...
});
```

If you merely want to watch for the array being changed, like an object being
replaced, added or removed, use `[]` instead of `@each`.

```javascript
myMethod: computed('posts.[]', function(){
...
});
```

@property @each
@deprecated
@public
*/
'@each': ARRAY_AT_EACH
? nonEnumerableComputed(function() {
deprecate(`Getting the '@each' property on object ${toString(this)} is deprecated`, false, {
id: 'ember-metal.getting-each',
until: '3.5.0',
url: 'https://emberjs.com/deprecations/v3.x#toc_getting-the-each-property',
});

return eachProxyFor(this);
}).readOnly()
: undefined,
});

/**
Expand Down Expand Up @@ -1624,19 +1582,6 @@ let NativeArray = Mixin.create(MutableArray, Observable, {

return this;
},

copy(deep) {
deprecate(`Using \`NativeArray#copy\` is deprecated`, false, {
id: 'ember-runtime.using-array-copy',
until: '3.5.0',
});

if (deep) {
return this.map(item => copy(item, true));
}

return this.slice();
},
});

// Remove any methods implemented natively so we don't override them
Expand Down
35 changes: 0 additions & 35 deletions packages/@ember/-internals/runtime/tests/mixins/array_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,6 @@ moduleFor(
assert.equal(called, 1, 'calls observer when object is pushed');
}

['@test getting @each is deprecated'](assert) {
assert.expect(1);

expectDeprecation(() => {
get(ary, '@each');
}, /Getting the '@each' property on object .* is deprecated/);
}

['@test @each is readOnly'](assert) {
assert.expect(1);

assert.throws(function() {
set(ary, '@each', 'foo');
}, /Cannot set read-only property "@each"/);
}

['@test using @each to observe arrays that does not return objects raise error'](assert) {
let called = 0;

Expand Down Expand Up @@ -328,25 +312,6 @@ moduleFor(
assert.equal(called, 0, 'not calls observer when object is pushed');
}

['@test modifying the array should also indicate the isDone prop itself has changed'](assert) {
// NOTE: we never actually get the '@each.isDone' property here. This is
// important because it tests the case where we don't have an isDone
// EachArray materialized but just want to know when the property has
// changed.
let each;
expectDeprecation(() => {
each = get(ary, '@each');
});
let count = 0;

addObserver(each, 'isDone', () => count++);

count = 0;
let item = objectAt(ary, 2);
set(item, 'isDone', !get(item, 'isDone'));
assert.equal(count, 1, '@each.isDone should have notified');
}

['@test `objectAt` returns correct object'](assert) {
let arr = ['first', 'second', 'third', 'fourth'];
assert.equal(objectAt(arr, 2), 'third');
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/@ember/deprecated-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const SEND_ACTION = !!'3.4.0';
export const EMBER_EXTEND_PROTOTYPES = !!'3.2.0-beta.5';
export const RUN_SYNC = !!'3.0.0-beta.4';
export const LOGGER = !!'3.2.0-beta.1';
export const ARRAY_AT_EACH = !!'3.1.0-beta.1';
export const MERGE = !!'3.6.0-beta.1';
export const HANDLER_INFOS = !!'3.9.0';
export const ROUTER_EVENTS = !!'3.9.0';
Expand Down
1 change: 0 additions & 1 deletion tests/docs/expected.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = {
classitems: [
'$',
'@each',
'A',
'EXTEND_PROTOTYPES',
'GUID_KEY',
Expand Down