Skip to content

Commit

Permalink
Merge pull request #19642 from nlfurniss/remove-aliasmethod
Browse files Browse the repository at this point in the history
Remove aliasMethod
  • Loading branch information
chancancode committed Jul 18, 2021
2 parents 255a0dd + 8967ad9 commit 7b68741
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 225 deletions.
2 changes: 1 addition & 1 deletion packages/@ember/-internals/metal/index.ts
Expand Up @@ -50,7 +50,7 @@ export {
removeObserver,
flushAsyncObservers,
} from './lib/observer';
export { Mixin, aliasMethod, mixin, observer, applyMixin } from './lib/mixin';
export { Mixin, mixin, observer, applyMixin } from './lib/mixin';
export { default as inject, DEBUG_INJECTION_FUNCTIONS } from './lib/injected_property';
export { tagForProperty, tagForObject, markObjectAsDirty } from './lib/tags';
export { tracked, TrackedDescriptor } from './lib/tracked';
Expand Down
119 changes: 1 addition & 118 deletions packages/@ember/-internals/metal/lib/mixin.ts
Expand Up @@ -13,8 +13,7 @@ import {
wrap,
} from '@ember/-internals/utils';
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { assert, deprecate } from '@ember/debug';
import { ALIAS_METHOD } from '@ember/deprecated-features';
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { _WeakSet } from '@glimmer/util';
import {
Expand All @@ -26,7 +25,6 @@ import {
import {
ComputedDescriptor,
descriptorForDecorator,
descriptorForProperty,
makeComputedDecorator,
nativeDescDecorator,
} from './decorator';
Expand Down Expand Up @@ -366,39 +364,6 @@ function mergeProps(
}
}

let followMethodAlias: (
obj: object,
alias: Alias,
descs: { [key: string]: any },
values: { [key: string]: any }
) => { desc: any; value: any };

if (ALIAS_METHOD) {
followMethodAlias = function (
obj: object,
alias: Alias,
descs: { [key: string]: any },
values: { [key: string]: any }
) {
let altKey = alias.methodName;
let possibleDesc;
let desc = descs[altKey];
let value = values[altKey];

if (desc !== undefined || value !== undefined) {
// do nothing
} else if ((possibleDesc = descriptorForProperty(obj, altKey)) !== undefined) {
desc = possibleDesc;
value = undefined;
} else {
desc = undefined;
value = obj[altKey];
}

return { desc, value };
};
}

function updateObserversAndListeners(obj: object, key: string, fn: Function, add: boolean) {
let meta = observerListenerMetaFor(fn);

Expand Down Expand Up @@ -446,14 +411,6 @@ export function applyMixin(obj: { [key: string]: any }, mixins: Mixin[], _hideKe
let value = values[key];
let desc = descs[key];

if (ALIAS_METHOD) {
while (value !== undefined && isAlias(value)) {
let followed = followMethodAlias(obj, value, descs, values);
desc = followed.desc;
value = followed.value;
}
}

if (value !== undefined) {
if (typeof value === 'function') {
updateObserversAndListeners(obj, key, value, true);
Expand Down Expand Up @@ -785,80 +742,6 @@ function _keys(mixin: Mixin, ret = new Set(), seen = new Set()) {
return ret;
}

declare class Alias {
public methodName: string;
constructor(methodName: string);
}

let AliasImpl: typeof Alias;

let isAlias: (alias: any) => alias is Alias;

if (ALIAS_METHOD) {
const ALIASES = new _WeakSet();

isAlias = (alias: any): alias is Alias => {
return ALIASES.has(alias);
};

AliasImpl = class AliasImpl {
constructor(public methodName: string) {
ALIASES.add(this);
}
} as typeof Alias;
}

/**
Makes a method available via an additional name.
```app/utils/person.js
import EmberObject, {
aliasMethod
} from '@ember/object';
export default EmberObject.extend({
name() {
return 'Tomhuda Katzdale';
},
moniker: aliasMethod('name')
});
```
```javascript
let goodGuy = Person.create();
goodGuy.name(); // 'Tomhuda Katzdale'
goodGuy.moniker(); // 'Tomhuda Katzdale'
```
@method aliasMethod
@static
@deprecated Use a shared utility method instead
@for @ember/object
@param {String} methodName name of the method to alias
@public
*/
export let aliasMethod: (methodName: string) => any;

if (ALIAS_METHOD) {
aliasMethod = function aliasMethod(methodName: string): Alias {
deprecate(
`You attempted to alias '${methodName}, but aliasMethod has been deprecated. Consider extracting the method into a shared utility function.`,
false,
{
id: 'object.alias-method',
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x#toc_object-alias-method',
for: 'ember-source',
since: {
enabled: '3.9.0',
},
}
);
return new AliasImpl(methodName);
};
}

// ..........................................................
// OBSERVER HELPER
//
Expand Down
101 changes: 0 additions & 101 deletions packages/@ember/-internals/metal/tests/mixin/alias_method_test.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/@ember/deprecated-features/index.ts
Expand Up @@ -9,7 +9,6 @@ export const MERGE = !!'3.6.0-beta.1';
export const ROUTER_EVENTS = !!'4.0.0';
export const COMPONENT_MANAGER_STRING_LOOKUP = !!'3.8.0';
export const JQUERY_INTEGRATION = !!'3.9.0';
export const ALIAS_METHOD = !!'3.9.0';
export const APP_CTRL_ROUTER_PROPS = !!'3.10.0-beta.1';
export const FUNCTION_PROTOTYPE_EXTENSIONS = !!'3.11.0-beta.1';
export const MOUSE_ENTER_LEAVE_MOVE_EVENTS = !!'3.13.0-beta.1';
Expand Down
1 change: 0 additions & 1 deletion packages/@ember/object/index.js
Expand Up @@ -16,7 +16,6 @@ export {
observer,
computed,
trySet,
aliasMethod,
} from '@ember/-internals/metal';

import { computed } from '@ember/-internals/metal';
Expand Down
1 change: 0 additions & 1 deletion packages/ember/index.js
Expand Up @@ -305,7 +305,6 @@ Ember.setProperties = metal.setProperties;
Ember.expandProperties = metal.expandProperties;
Ember.addObserver = metal.addObserver;
Ember.removeObserver = metal.removeObserver;
Ember.aliasMethod = metal.aliasMethod;
Ember.observer = metal.observer;
Ember.mixin = metal.mixin;
Ember.Mixin = metal.Mixin;
Expand Down
1 change: 0 additions & 1 deletion packages/ember/tests/reexports_test.js
Expand Up @@ -282,7 +282,6 @@ let allExports = [
// @ember/object
['Object', '@ember/object', 'default'],
['_action', '@ember/object', 'action'],
['aliasMethod', '@ember/object', 'aliasMethod'],
['computed', '@ember/object', 'computed'],
['defineProperty', '@ember/object', 'defineProperty'],
['get', '@ember/object', 'get'],
Expand Down
1 change: 0 additions & 1 deletion tests/docs/expected.js
Expand Up @@ -75,7 +75,6 @@ module.exports = {
'advanceReadiness',
'afterModel',
'alias',
'aliasMethod',
'all',
'allSettled',
'and',
Expand Down

0 comments on commit 7b68741

Please sign in to comment.