Skip to content

Commit

Permalink
Remove run and computed dot access
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Jul 18, 2021
1 parent 9149433 commit cafda2b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 290 deletions.
128 changes: 0 additions & 128 deletions packages/@ember/object/index.js
Expand Up @@ -19,134 +19,6 @@ export {

import { computed } from '@ember/-internals/metal';

import {
alias,
and,
bool,
collect,
deprecatingAlias,
empty,
equal,
filterBy,
filter,
gte,
gt,
intersect,
lte,
lt,
mapBy,
map,
match,
max,
min,
none,
notEmpty,
not,
oneWay,
or,
readOnly,
setDiff,
sort,
sum,
union,
uniqBy,
uniq,
} from '@ember/object/computed';

// eslint-disable-next-line no-undef
if (DEBUG) {
let defaultHandler = (dotKey, importKey, module) => {
return `Using \`${dotKey}\` has been deprecated. Instead, import the value directly from ${module}:\n\n import { ${importKey} } from '${module}';`;
};

let handler = onComputedDotAccess || defaultHandler;

let defineDeprecatedComputedFunc = (key, func) => {
Object.defineProperty(computed, key, {
get() {
let message = handler(`computed.${key}`, key, '@ember/object/computed');

deprecate(message, message === null, {
id: 'deprecated-run-loop-and-computed-dot-access',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.27.0',
},
});

return func;
},
});
};

defineDeprecatedComputedFunc('alias', alias);
defineDeprecatedComputedFunc('and', and);
defineDeprecatedComputedFunc('bool', bool);
defineDeprecatedComputedFunc('collect', collect);
defineDeprecatedComputedFunc('deprecatingAlias', deprecatingAlias);
defineDeprecatedComputedFunc('empty', empty);
defineDeprecatedComputedFunc('equal', equal);
defineDeprecatedComputedFunc('filterBy', filterBy);
defineDeprecatedComputedFunc('filter', filter);
defineDeprecatedComputedFunc('gte', gte);
defineDeprecatedComputedFunc('gt', gt);
defineDeprecatedComputedFunc('intersect', intersect);
defineDeprecatedComputedFunc('lte', lte);
defineDeprecatedComputedFunc('lt', lt);
defineDeprecatedComputedFunc('mapBy', mapBy);
defineDeprecatedComputedFunc('map', map);
defineDeprecatedComputedFunc('match', match);
defineDeprecatedComputedFunc('max', max);
defineDeprecatedComputedFunc('min', min);
defineDeprecatedComputedFunc('none', none);
defineDeprecatedComputedFunc('notEmpty', notEmpty);
defineDeprecatedComputedFunc('not', not);
defineDeprecatedComputedFunc('oneWay', oneWay);
defineDeprecatedComputedFunc('reads', oneWay);
defineDeprecatedComputedFunc('or', or);
defineDeprecatedComputedFunc('readOnly', readOnly);
defineDeprecatedComputedFunc('setDiff', setDiff);
defineDeprecatedComputedFunc('sort', sort);
defineDeprecatedComputedFunc('sum', sum);
defineDeprecatedComputedFunc('union', union);
defineDeprecatedComputedFunc('uniqBy', uniqBy);
defineDeprecatedComputedFunc('uniq', uniq);
} else {
computed.alias = alias;
computed.and = and;
computed.bool = bool;
computed.collect = collect;
computed.deprecatingAlias = deprecatingAlias;
computed.empty = empty;
computed.equal = equal;
computed.filterBy = filterBy;
computed.filter = filter;
computed.gte = gte;
computed.gt = gt;
computed.intersect = intersect;
computed.lte = lte;
computed.lt = lt;
computed.mapBy = mapBy;
computed.map = map;
computed.match = match;
computed.max = max;
computed.min = min;
computed.none = none;
computed.notEmpty = notEmpty;
computed.not = not;
computed.oneWay = oneWay;
computed.reads = oneWay;
computed.or = or;
computed.readOnly = readOnly;
computed.setDiff = setDiff;
computed.sort = sort;
computed.sum = sum;
computed.union = union;
computed.uniqBy = uniqBy;
computed.uniq = uniq;
}

/**
Decorator that turns the target function into an Action which can be accessed
directly by reference.
Expand Down
48 changes: 24 additions & 24 deletions packages/@ember/object/tests/computed/computed_macros_test.js
Expand Up @@ -23,7 +23,7 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
moduleFor(
'CP macros',
class extends AbstractTestCase {
['@test Ember.computed.empty'](assert) {
['@test empty'](assert) {
let obj = EmberObject.extend({
bestLannister: null,
lannisters: null,
Expand All @@ -44,7 +44,7 @@ moduleFor(
assert.equal(get(obj, 'noLannistersKnown'), false, 'empty respects array mutations');
}

['@test Ember.computed.notEmpty'](assert) {
['@test notEmpty'](assert) {
let obj = EmberObject.extend({
bestLannister: null,
lannisters: null,
Expand All @@ -65,7 +65,7 @@ moduleFor(
assert.equal(get(obj, 'LannistersKnown'), true, 'empty respects array mutations');
}

['@test computed.not'](assert) {
['@test not'](assert) {
let obj = { foo: true };
defineProperty(obj, 'notFoo', not('foo'));
assert.equal(get(obj, 'notFoo'), false);
Expand All @@ -75,7 +75,7 @@ moduleFor(
assert.equal(get(obj, 'notFoo'), false);
}

['@test computed.empty'](assert) {
['@test empty'](assert) {
let obj = { foo: [], bar: undefined, baz: null, quz: '' };
defineProperty(obj, 'fooEmpty', empty('foo'));
defineProperty(obj, 'barEmpty', empty('bar'));
Expand All @@ -92,7 +92,7 @@ moduleFor(
assert.equal(get(obj, 'quzEmpty'), false);
}

['@test computed.bool'](assert) {
['@test bool'](assert) {
let obj = { foo() {}, bar: 'asdf', baz: null, quz: false };
defineProperty(obj, 'fooBool', bool('foo'));
defineProperty(obj, 'barBool', bool('bar'));
Expand All @@ -104,7 +104,7 @@ moduleFor(
assert.equal(get(obj, 'quzBool'), false);
}

['@test computed.alias'](assert) {
['@test alias'](assert) {
let obj = { bar: 'asdf', baz: null, quz: false };
defineProperty(
obj,
Expand Down Expand Up @@ -137,7 +137,7 @@ moduleFor(
assert.equal(get(obj, 'quz'), null);
}

['@test computed.alias set'](assert) {
['@test alias set'](assert) {
let obj = {};
let constantValue = 'always `a`';

Expand All @@ -164,7 +164,7 @@ moduleFor(
assert.equal(get(obj, 'aliased'), constantValue);
}

['@test computed.match'](assert) {
['@test match'](assert) {
let obj = { name: 'Paul' };
defineProperty(obj, 'isPaul', match('name', /Paul/));

Expand All @@ -175,7 +175,7 @@ moduleFor(
assert.equal(get(obj, 'isPaul'), false, 'is not Paul anymore');
}

['@test computed.notEmpty'](assert) {
['@test notEmpty'](assert) {
let obj = { items: [1] };
defineProperty(obj, 'hasItems', notEmpty('items'));

Expand All @@ -186,7 +186,7 @@ moduleFor(
assert.equal(get(obj, 'hasItems'), false, 'is empty');
}

['@test computed.equal'](assert) {
['@test equal'](assert) {
let obj = { name: 'Paul' };
defineProperty(obj, 'isPaul', computedEqual('name', 'Paul'));

Expand All @@ -197,7 +197,7 @@ moduleFor(
assert.equal(get(obj, 'isPaul'), false, 'is not Paul anymore');
}

['@test computed.gt'](assert) {
['@test gt'](assert) {
let obj = { number: 2 };
defineProperty(obj, 'isGreaterThenOne', gt('number', 1));

Expand All @@ -212,7 +212,7 @@ moduleFor(
assert.equal(get(obj, 'isGreaterThenOne'), false, 'is not gt');
}

['@test computed.gte'](assert) {
['@test gte'](assert) {
let obj = { number: 2 };
defineProperty(obj, 'isGreaterOrEqualThenOne', gte('number', 1));

Expand All @@ -227,7 +227,7 @@ moduleFor(
assert.equal(get(obj, 'isGreaterOrEqualThenOne'), false, 'is not gte');
}

['@test computed.lt'](assert) {
['@test lt'](assert) {
let obj = { number: 0 };
defineProperty(obj, 'isLesserThenOne', lt('number', 1));

Expand All @@ -242,7 +242,7 @@ moduleFor(
assert.equal(get(obj, 'isLesserThenOne'), false, 'is not lt');
}

['@test computed.lte'](assert) {
['@test lte'](assert) {
let obj = { number: 0 };
defineProperty(obj, 'isLesserOrEqualThenOne', lte('number', 1));

Expand All @@ -257,7 +257,7 @@ moduleFor(
assert.equal(get(obj, 'isLesserOrEqualThenOne'), false, 'is not lte');
}

['@test computed.and two properties'](assert) {
['@test and, with two properties'](assert) {
let obj = { one: true, two: true };
defineProperty(obj, 'oneAndTwo', and('one', 'two'));

Expand All @@ -278,7 +278,7 @@ moduleFor(
assert.equal(get(obj, 'oneAndTwo'), 2, 'returns truthy value as in &&');
}

['@test computed.and three properties'](assert) {
['@test and, with three properties'](assert) {
let obj = { one: true, two: true, three: true };
defineProperty(obj, 'oneTwoThree', and('one', 'two', 'three'));

Expand All @@ -295,7 +295,7 @@ moduleFor(
assert.equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&');
}

['@test computed.and expand properties'](assert) {
['@test and, with expand properties'](assert) {
let obj = { one: true, two: true, three: true };
defineProperty(obj, 'oneTwoThree', and('{one,two,three}'));

Expand All @@ -312,7 +312,7 @@ moduleFor(
assert.equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&');
}

['@test computed.or two properties'](assert) {
['@test or, with two properties'](assert) {
let obj = { one: true, two: true };
defineProperty(obj, 'oneOrTwo', or('one', 'two'));

Expand All @@ -339,7 +339,7 @@ moduleFor(
assert.equal(get(obj, 'oneOrTwo'), 1, 'returns truthy value as in ||');
}

['@test computed.or three properties'](assert) {
['@test or, with three properties'](assert) {
let obj = { one: true, two: true, three: true };
defineProperty(obj, 'oneTwoThree', or('one', 'two', 'three'));

Expand Down Expand Up @@ -370,7 +370,7 @@ moduleFor(
assert.equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||');
}

['@test computed.or expand properties'](assert) {
['@test or, with expand properties'](assert) {
let obj = { one: true, two: true, three: true };
defineProperty(obj, 'oneTwoThree', or('{one,two,three}'));

Expand Down Expand Up @@ -401,7 +401,7 @@ moduleFor(
assert.equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||');
}

['@test computed.or and computed.and warn about dependent keys with spaces']() {
['@test or and and, warn about dependent keys with spaces']() {
let obj = { one: true, two: true };
expectAssertion(function () {
defineProperty(obj, 'oneOrTwo', or('one', 'two three'));
Expand All @@ -412,7 +412,7 @@ moduleFor(
}, /Dependent keys passed to computed\.and\(\) can't have spaces\./);
}

['@test computed.oneWay'](assert) {
['@test oneWay'](assert) {
let obj = {
firstName: 'Teddy',
lastName: 'Zeenny',
Expand All @@ -436,7 +436,7 @@ moduleFor(
assert.equal(get(obj, 'nickName'), 'TeddyBear');
}

['@test computed.readOnly'](assert) {
['@test readOnly'](assert) {
let obj = {
firstName: 'Teddy',
lastName: 'Zeenny',
Expand All @@ -462,7 +462,7 @@ moduleFor(
assert.equal(get(obj, 'nickName'), 'TEDDDDDDDDYYY');
}

['@test computed.deprecatingAlias'](assert) {
['@test deprecatingAlias'](assert) {
let obj = { bar: 'asdf', baz: null, quz: false };
defineProperty(
obj,
Expand Down

0 comments on commit cafda2b

Please sign in to comment.