From 8faddaf98e502b65f62574a3e2ecda5a4dc64134 Mon Sep 17 00:00:00 2001 From: Nathaniel Furniss Date: Wed, 21 Jul 2021 19:09:12 -0700 Subject: [PATCH] Remove .property() --- .../@ember/-internals/metal/lib/computed.ts | 85 ------------------- .../tests/system/object/computed_test.js | 20 ----- tests/docs/expected.js | 1 - 3 files changed, 106 deletions(-) diff --git a/packages/@ember/-internals/metal/lib/computed.ts b/packages/@ember/-internals/metal/lib/computed.ts index 9f261df8c6f..7e38a65c1a6 100644 --- a/packages/@ember/-internals/metal/lib/computed.ts +++ b/packages/@ember/-internals/metal/lib/computed.ts @@ -733,81 +733,6 @@ class ComputedDecoratorImpl extends Function { return this; } - /** - Sets the dependent keys on this computed property. Pass any number of - arguments containing key paths that this computed property depends on. - - Example: - - ```javascript - import EmberObject, { computed } from '@ember/object'; - - class President { - constructor(firstName, lastName) { - set(this, 'firstName', firstName); - set(this, 'lastName', lastName); - } - - // Tell Ember that this computed property depends on firstName - // and lastName - @computed().property('firstName', 'lastName') - get fullName() { - return `${this.firstName} ${this.lastName}`; - } - } - - let president = new President('Barack', 'Obama'); - - president.fullName; // 'Barack Obama' - ``` - - Classic Class Example: - - ```javascript - import EmberObject, { computed } from '@ember/object'; - - let President = EmberObject.extend({ - fullName: computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); - - // Tell Ember that this computed property depends on firstName - // and lastName - }).property('firstName', 'lastName') - }); - - let president = President.create({ - firstName: 'Barack', - lastName: 'Obama' - }); - - president.get('fullName'); // 'Barack Obama' - ``` - - @method property - @deprecated - @param {String} path* zero or more property paths - @return {ComputedProperty} this - @chainable - @public - */ - property(this: Decorator, ...keys: string[]) { - deprecate( - 'Setting dependency keys using the `.property()` modifier has been deprecated. Pass the dependency keys directly to computed as arguments instead. If you are using `.property()` on a computed property macro, consider refactoring your macro to receive additional dependent keys in its initial declaration.', - false, - { - id: 'computed-property.property', - until: '4.0.0', - url: 'https://deprecations.emberjs.com/v3.x#toc_computed-property-property', - for: 'ember-source', - since: { - enabled: '3.9.0-beta.1', - }, - } - ); - (descriptorForDecorator(this) as ComputedProperty)._property(...keys); - return this; - } - /** In some cases, you may want to annotate computed properties with additional metadata about how they function or what values they operate on. For example, @@ -1010,16 +935,6 @@ class ComputedDecoratorImpl extends Function { libraries that depend on or use Ember, since there is no guarantee that the user will have [prototype Extensions](https://guides.emberjs.com/release/configuring-ember/disabling-prototype-extensions/) enabled._ - The alternative syntax, with prototype extensions, might look like: - - ```js - fullName: function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }.property('firstName', 'lastName') - ``` - - This form does not work with native decorators. - @method computed @for @ember/object @static diff --git a/packages/@ember/-internals/runtime/tests/system/object/computed_test.js b/packages/@ember/-internals/runtime/tests/system/object/computed_test.js index 44552bda829..e3acf280d7a 100644 --- a/packages/@ember/-internals/runtime/tests/system/object/computed_test.js +++ b/packages/@ember/-internals/runtime/tests/system/object/computed_test.js @@ -363,26 +363,6 @@ moduleFor( obj2.destroy(); } - ['@test can declare dependent keys with .property()'](assert) { - let Obj; - - expectDeprecation(() => { - Obj = EmberObject.extend({ - foo: computed(function () { - return this.bar; - }).property('bar'), - }); - }, /Setting dependency keys using the `.property\(\)` modifier has been deprecated/); - - let obj = Obj.create({ bar: 1 }); - - assert.equal(obj.get('foo'), 1); - - obj.set('bar', 2); - - assert.equal(obj.get('foo'), 2); - } - ['@test native getters and setters work'](assert) { let MyClass = EmberObject.extend({ bar: 123, diff --git a/tests/docs/expected.js b/tests/docs/expected.js index efbb3376ffc..97d56d74519 100644 --- a/tests/docs/expected.js +++ b/tests/docs/expected.js @@ -417,7 +417,6 @@ module.exports = { 'positionalParams', 'preventDefault', 'promise', - 'property', 'pushObject', 'pushObjects', 'pushState',