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] Restore nested paths on run and computed #19464

Merged
merged 1 commit into from Mar 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/@ember/-internals/metal/index.ts
@@ -1,10 +1,4 @@
export {
default as computed,
autoComputed,
isComputed,
_globalsComputed,
ComputedProperty,
} from './lib/computed';
export { default as computed, autoComputed, isComputed, ComputedProperty } from './lib/computed';
export { getCachedValueFor } from './lib/computed_cache';
export { default as alias } from './lib/alias';
export { deprecateProperty } from './lib/deprecate_property';
Expand Down
2 changes: 0 additions & 2 deletions packages/@ember/-internals/metal/lib/computed.ts
Expand Up @@ -1079,6 +1079,4 @@ export function isComputed(obj: object, key: string): boolean {
return Boolean(descriptorForProperty(obj, key));
}

export const _globalsComputed = computed.bind(null);

export default computed;
129 changes: 128 additions & 1 deletion packages/@ember/object/index.js
@@ -1,4 +1,5 @@
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { assert, deprecate } from '@ember/debug';
import { assign } from '@ember/polyfills';
import { isElementDescriptor, setClassicDecorator } from '@ember/-internals/metal';

Expand All @@ -18,6 +19,132 @@ export {
aliasMethod,
} from '@ember/-internals/metal';

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 defineDeprecatedComputedFunc = (key, func) => {
Object.defineProperty(computed, key, {
get() {
deprecate(
`Using \`computed.${key}\` has been deprecated. Instead, import the value directly from @ember/object/computed:\n\n import { ${key} } from '@ember/runloop';`,
false,
{
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
66 changes: 62 additions & 4 deletions packages/@ember/runloop/index.js
@@ -1,4 +1,5 @@
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { assert, deprecate } from '@ember/debug';
import { onErrorTarget } from '@ember/-internals/error-handling';
import { flushAsyncObservers } from '@ember/-internals/metal';
import Backburner from 'backburner';
Expand Down Expand Up @@ -103,9 +104,6 @@ export function run() {
return backburner.run(...arguments);
}

// used for the Ember.run global only
export const _globalsRun = run.bind(null);

/**
If no run-loop is present, it creates a new one. If a run loop is
present it will queue itself to run on the existing run-loops action
Expand Down Expand Up @@ -742,3 +740,63 @@ export function debounce() {
export function throttle() {
return backburner.throttle(...arguments);
}

// eslint-disable-next-line no-undef
if (DEBUG) {
let defineDeprecatedRunloopFunc = (key, func, alt) => {
Object.defineProperty(run, key, {
get() {
deprecate(
`Using \`run.${key}\` has been deprecated. Instead, import the value directly from @ember/runloop:\n\n import { ${
alt || key
} } from '@ember/runloop';`,
false,
{
id: 'deprecated-run-loop-and-computed-dot-access',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.27.0',
},
}
);

return func;
},
});
};

defineDeprecatedRunloopFunc('backburner', backburner);
defineDeprecatedRunloopFunc('begin', begin);
defineDeprecatedRunloopFunc('bind', bind);
defineDeprecatedRunloopFunc('cancel', cancel);
defineDeprecatedRunloopFunc('debounce', debounce);
defineDeprecatedRunloopFunc('end', end);
defineDeprecatedRunloopFunc('hasScheduledTimers', hasScheduledTimers);
defineDeprecatedRunloopFunc('join', join);
defineDeprecatedRunloopFunc('later', later);
defineDeprecatedRunloopFunc('next', next);
defineDeprecatedRunloopFunc('once', once);
defineDeprecatedRunloopFunc('schedule', schedule);
defineDeprecatedRunloopFunc('scheduleOnce', scheduleOnce);
defineDeprecatedRunloopFunc('throttle', throttle);
defineDeprecatedRunloopFunc('cancelTimers', cancelTimers);
defineDeprecatedRunloopFunc('currentRunLoop', getCurrentRunLoop, 'getCurrentRunLoop');
} else {
run.backburner = backburner;
run.begin = begin;
run.bind = bind;
run.cancel = cancel;
run.debounce = debounce;
run.end = end;
run.hasScheduledTimers = hasScheduledTimers;
run.join = join;
run.later = later;
run.next = next;
run.once = once;
run.schedule = schedule;
run.scheduleOnce = scheduleOnce;
run.throttle = throttle;
run.cancelTimers = cancelTimers;
run.currentRunLoop = getCurrentRunLoop;
}
96 changes: 3 additions & 93 deletions packages/ember/index.js
Expand Up @@ -33,42 +33,9 @@ import {
} from '@ember/string';
import Service, { inject as injectService } from '@ember/service';

import { action } from '@ember/object';
import { action, computed } from '@ember/object';
import { dependentKeyCompat } from '@ember/object/compat';

import {
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';

import {
Object as EmberObject,
RegistryProxyMixin,
Expand Down Expand Up @@ -124,7 +91,7 @@ import * as views from '@ember/-internals/views';
import * as routing from '@ember/-internals/routing';
import * as extensionSupport from '@ember/-internals/extension-support';
import EmberError from '@ember/error';
import * as runloop from '@ember/runloop';
import { run } from '@ember/runloop';
import { getOnerror, setOnerror } from '@ember/-internals/error-handling';
import { getOwner, setOwner } from '@ember/-internals/owner';
import Application, { onLoad, runLoadHooks } from '@ember/application';
Expand Down Expand Up @@ -311,37 +278,14 @@ Ember.Instrumentation = {

// ****@ember/runloop****

// Using _globalsRun here so that mutating the function (adding
// `next`, `later`, etc to it) is only available in globals builds
Ember.run = runloop._globalsRun;
Ember.run.backburner = runloop.backburner;
Ember.run.begin = runloop.begin;
Ember.run.bind = runloop.bind;
Ember.run.cancel = runloop.cancel;
Ember.run.debounce = runloop.debounce;
Ember.run.end = runloop.end;
Ember.run.hasScheduledTimers = runloop.hasScheduledTimers;
Ember.run.join = runloop.join;
Ember.run.later = runloop.later;
Ember.run.next = runloop.next;
Ember.run.once = runloop.once;
Ember.run.schedule = runloop.schedule;
Ember.run.scheduleOnce = runloop.scheduleOnce;
Ember.run.throttle = runloop.throttle;
Ember.run.cancelTimers = runloop.cancelTimers;
Object.defineProperty(Ember.run, 'currentRunLoop', {
get: runloop.getCurrentRunLoop,
enumerable: false,
});
Ember.run = run;

// ****@ember/-internals/metal****

// in globals builds
const computed = metal._globalsComputed;
Ember.computed = computed;
Ember._descriptor = metal.nativeDescDecorator;
Ember._tracked = metal.tracked;
computed.alias = metal.alias;
Ember.cacheFor = metal.getCachedValueFor;
Ember.ComputedProperty = metal.ComputedProperty;
Ember._setClassicDecorator = metal.setClassicDecorator;
Expand Down Expand Up @@ -507,40 +451,6 @@ Ember.Namespace = Namespace;
Ember._action = action;
Ember._dependentKeyCompat = dependentKeyCompat;

computed.empty = empty;
computed.notEmpty = notEmpty;
computed.none = none;
computed.not = not;
computed.bool = bool;
computed.match = match;
computed.equal = equal;
computed.gt = gt;
computed.gte = gte;
computed.lt = lt;
computed.lte = lte;
computed.oneWay = oneWay;
computed.reads = oneWay;
computed.readOnly = readOnly;
computed.deprecatingAlias = deprecatingAlias;
computed.and = and;
computed.or = or;

computed.sum = sum;
computed.min = min;
computed.max = max;
computed.map = map;
computed.sort = sort;
computed.setDiff = setDiff;
computed.mapBy = mapBy;
computed.filter = filter;
computed.filterBy = filterBy;
computed.uniq = uniq;

computed.uniqBy = uniqBy;
computed.union = union;
computed.intersect = intersect;
computed.collect = collect;

/**
Defines the hash of localized strings for the current language. Used by
the `String.loc` helper. To localize, add string values to this
Expand Down