Skip to content
Draft
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
7 changes: 7 additions & 0 deletions packages/@ember/-internals/deprecations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ export const DEPRECATIONS = {
until: '8.0.0',
url: 'https://deprecations.emberjs.com/id/deprecate-ember-utils',
}),
DEPRECATE_CLASSIC_CLASSES: deprecation({
id: 'deprecate-classic-classes',
for: 'ember-source',
since: { available: '7.5.0' },
until: '8.0.0',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably needs to move to v9, in coordination with RFC#1234

url: 'https://deprecations.emberjs.com/id/deprecate-classic-classes',
}),
};

export function deprecateUntil(message: string, deprecation: DeprecationObject) {
Expand Down
8 changes: 6 additions & 2 deletions packages/@ember/-internals/glimmer/lib/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import {
getComponentCapturedArgs,
} from './component-managers/curly';
import hasDOM from '@ember/-internals/browser-environment/lib/has-dom';
import {
INTERNAL_EXTEND,
INTERNAL_REOPEN_CLASS,
} from '@ember/-internals/utils/lib/internal-classic-class';

// Keep track of which component classes have already been processed for lazy event setup.
let lazyEventsProcessed = new WeakMap<EventDispatcher, WeakSet<object>>();
Expand Down Expand Up @@ -802,7 +806,7 @@ interface Component<S = unknown>
extends CoreView, TargetActionSupport, ActionSupport, ComponentMethods {}

class Component<S = unknown>
extends CoreView.extend(
extends CoreView[INTERNAL_EXTEND](
TargetActionSupport,
ActionSupport,
{
Expand Down Expand Up @@ -1687,7 +1691,7 @@ class Component<S = unknown>
}

// We continue to use reopenClass here so that positionalParams can be overridden with reopenClass in subclasses.
Component.reopenClass({
Component[INTERNAL_REOPEN_CLASS]({
positionalParams: [],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ moduleFor(
}
};

FooBarComponent.reopenClass({
positionalParams: ['firstPositional'],
});
FooBarComponent.positionalParams = ['firstPositional'];

this.owner.register('component:foo-bar', FooBarComponent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
runLoopSettled,
expectDeprecation,
testUnless,
expectClassicClassDeprecation,
} from 'internal-test-helpers';
import { DEPRECATIONS } from '../../../../../deprecations';
import { action } from '@ember/object';
Expand Down Expand Up @@ -1968,7 +1969,11 @@ moduleFor(
this.assertText('things');
}

async ['@test didReceiveAttrs fires after .init() but before observers become active'](assert) {
async [`${testUnless(DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test didReceiveAttrs fires after .init() but before observers become active`](
assert
) {
expectClassicClassDeprecation();

let barCopyDidChangeCount = 0;

this.owner.register(
Expand Down Expand Up @@ -2042,7 +2047,7 @@ moduleFor(
runTask(() => set(this.context, 'foo', 5));
}

[`${testUnless(DEPRECATIONS.DEPRECATE_EVENTED.isRemoved)} @test triggering an event only attempts to invoke an identically named method, if it actually is a function (GH#15228)`](
[`${testUnless(DEPRECATIONS.DEPRECATE_EVENTED.isRemoved || DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test triggering an event only attempts to invoke an identically named method, if it actually is a function (GH#15228)`](
assert
) {
assert.expect(5);
Expand All @@ -2051,6 +2056,8 @@ moduleFor(

expectDeprecation(
() => {
expectClassicClassDeprecation();

this.owner.register(
'component:evented-component',
Component.extend({
Expand Down Expand Up @@ -2111,7 +2118,9 @@ moduleFor(
this.assertText('hello');
}

['@test using attrs for positional params is asserted against']() {
[`${testUnless(DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test using attrs for positional params is asserted against`]() {
expectClassicClassDeprecation();

let MyComponent = class extends Component {};

expectAssertion(() => {
Expand All @@ -2129,16 +2138,20 @@ moduleFor(
}

// Perhaps change this test to `{{this.attrs.myVar.value}}` when removing the deprecation?
['@test using this.attrs for positional params']() {
[`${testUnless(DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test using this.attrs for positional params`]() {
expectClassicClassDeprecation();

let MyComponent = class extends Component {};

MyComponent.reopenClass({ positionalParams: ['myVar'] });

expectDeprecation(() => {
this.owner.register(
'component:foo-bar',
template(
'MyVar1: {{this.attrs.myVar}} {{this.myVar}} MyVar2: {{this.myVar2}} {{this.attrs.myVar2}}',
{
component: MyComponent.reopenClass({ positionalParams: ['myVar'] }),
component: MyComponent,
strictMode: false,
}
)
Expand All @@ -2150,7 +2163,9 @@ moduleFor(
this.assertText('MyVar1: 1 1 MyVar2: 2 2');
}

['@test using named arguments for positional params']() {
[`${testUnless(DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test using named arguments for positional params`]() {
expectClassicClassDeprecation();

let MyComponent = class extends Component {};

this.owner.register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
RenderingTestCase,
runTask,
testUnless,
expectClassicClassDeprecation,
} from 'internal-test-helpers';

import { action, set } from '@ember/object';
Expand Down Expand Up @@ -84,9 +85,9 @@ moduleFor(
runTask(() => component.send('foo', 'baz'));
}

[`${testUnless(
DEPRECATIONS.DEPRECATE_TARGET_ACTION_SUPPORT.isRemoved
)} @test a handled action can be bubbled to the target for continued processing`]() {
[`${testUnless(DEPRECATIONS.DEPRECATE_TARGET_ACTION_SUPPORT.isRemoved || DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test a handled action can be bubbled to the target for continued processing`]() {
expectClassicClassDeprecation();

this.assert.expect(3);

expectDeprecation(
Expand Down Expand Up @@ -124,9 +125,11 @@ moduleFor(
runTask(() => component.send('poke'));
}

[`${testUnless(
DEPRECATIONS.DEPRECATE_TARGET_ACTION_SUPPORT.isRemoved
)} @test action can be handled by a superclass' actions object`](assert) {
[`${testUnless(DEPRECATIONS.DEPRECATE_TARGET_ACTION_SUPPORT.isRemoved || DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test action can be handled by a superclass' actions object`](
assert
) {
expectClassicClassDeprecation();

this.assert.expect(5);

expectDeprecation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
runTask,
expectDeprecation,
testUnless,
expectClassicClassDeprecation,
} from 'internal-test-helpers';
import { DEPRECATIONS } from '@ember/-internals/deprecations';
import GlimmerishComponent from '../../utils/glimmerish-component';
Expand Down Expand Up @@ -62,9 +63,9 @@ moduleFor(
this.assertText('max jackson | max jackson');
}

[`${testUnless(
DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isRemoved
)} @test creating an array proxy inside a tracking context does not trigger backtracking assertion`]() {
[`${testUnless(DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isRemoved || DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test creating an array proxy inside a tracking context does not trigger backtracking assertion`]() {
expectClassicClassDeprecation();

expectDeprecation(/`ArrayProxy` is deprecated/, DEPRECATIONS.DEPRECATE_ARRAY_PROXY.isEnabled);
expectDeprecation(
/`PromiseProxyMixin` is deprecated/,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { DEPRECATIONS } from '@ember/-internals/deprecations';
import EmberObject from '@ember/object';
import { A } from '@ember/array';
import MutableArray from '@ember/array/mutable';
import { tracked, notifyPropertyChange } from '@ember/-internals/metal';
import Service, { service } from '@ember/service';
import { moduleFor, RenderingTestCase, runTask } from 'internal-test-helpers';
import {
moduleFor,
RenderingTestCase,
runTask,
testUnless,
expectClassicClassDeprecation,
} from 'internal-test-helpers';
import { precompileTemplate } from '@ember/template-compilation';
import { setComponentTemplate } from '@glimmer/manager';

Expand Down Expand Up @@ -172,7 +179,9 @@ moduleFor(
this.assertText('1, 2, 3, 4');
}

'@test custom ember array properties rerender when updated'() {
[`${testUnless(DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test custom ember array properties rerender when updated`]() {
expectClassicClassDeprecation();

let CustomArray = class extends EmberObject.extend(MutableArray) {
init() {
super.init(...arguments);
Expand Down
15 changes: 13 additions & 2 deletions packages/@ember/-internals/metal/tests/computed_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DEPRECATIONS } from '@ember/-internals/deprecations';
import EmberObject from '@ember/object';
import { meta as metaFor } from '@ember/-internals/meta';
import {
Expand All @@ -10,7 +11,13 @@ import {
addObserver,
} from '..';
import { run } from '@ember/runloop';
import { moduleFor, AbstractTestCase, runLoopSettled } from 'internal-test-helpers';
import {
moduleFor,
AbstractTestCase,
runLoopSettled,
testUnless,
expectClassicClassDeprecation,
} from 'internal-test-helpers';
import { destroy } from '@glimmer/destroyable';

let obj, objA, objB, count, func;
Expand Down Expand Up @@ -730,7 +737,11 @@ moduleFor(
}, /Cannot override the computed property `aInt` on <\(unknown\):ember\d*>./);
}

['@test the return value of the setter gets cached'](assert) {
[`${testUnless(DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved)} @test the return value of the setter gets cached`](
assert
) {
expectClassicClassDeprecation();

let testObj = EmberObject.extend({
a: '1',
sampleCP: computed('a', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import EmberObject from '@ember/object';
import { defineProperty, nativeDescDecorator } from '..';
import Mixin from '@ember/object/mixin';
import { moduleFor, AbstractTestCase, expectDeprecation } from 'internal-test-helpers';
import {
moduleFor,
AbstractTestCase,
expectDeprecation,
expectClassicClassDeprecation,
} from 'internal-test-helpers';
import { DEPRECATIONS } from '../../deprecations';

let classes = [
Expand Down Expand Up @@ -70,6 +75,8 @@ let classes = [
return `${title}: in EmberObject.extend()`;
}

static usesClassicClasses = true;

constructor() {
this.klass = null;
this.props = {};
Expand Down Expand Up @@ -98,6 +105,8 @@ let classes = [
return `${title}: in EmberObject.extend() through a mixin`;
}

static usesClassicClasses = true;

static usesMixins = true;

constructor() {
Expand Down Expand Up @@ -128,6 +137,8 @@ let classes = [
return `${title}: inherited from another EmberObject super class`;
}

static usesClassicClasses = true;

constructor() {
this.superklass = null;
this.props = {};
Expand All @@ -154,6 +165,10 @@ let classes = [

classes
.filter((TestClass) => !TestClass.usesMixins || !DEPRECATIONS.DEPRECATE_MIXINS.isRemoved)
.filter(
(TestClass) =>
!TestClass.usesClassicClasses || !DEPRECATIONS.DEPRECATE_CLASSIC_CLASSES.isRemoved
)
.forEach((TestClass) => {
moduleFor(
TestClass.module('@ember/-internals/metal/nativeDescDecorator'),
Expand All @@ -165,6 +180,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);

Expand Down Expand Up @@ -192,6 +210,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install(
Expand Down Expand Up @@ -227,6 +248,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install('foo', nativeDescDecorator({ enumerable: true, value: 'bar' }), assert);
Expand All @@ -247,6 +271,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install('foo', nativeDescDecorator({ enumerable: false, value: 'bar' }), assert);
Expand All @@ -267,6 +294,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install('foo', nativeDescDecorator({ writable: true, value: 'bar' }), assert);
Expand All @@ -293,6 +323,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install('foo', nativeDescDecorator({ writable: false, value: 'bar' }), assert);
Expand All @@ -316,6 +349,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install(
Expand Down Expand Up @@ -346,6 +382,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install(
Expand Down Expand Up @@ -376,6 +415,9 @@ classes
DEPRECATIONS.DEPRECATE_MIXINS.isEnabled
);
}
if (TestClass.usesClassicClasses) {
expectClassicClassDeprecation();
}

let factory = new TestClass(assert);
factory.install(
Expand Down
Loading
Loading