Skip to content

Commit

Permalink
Merge branch 'remove-manager-capabilities-deprecations' into update-g…
Browse files Browse the repository at this point in the history
…limmer-vm
  • Loading branch information
rwjblue committed Sep 29, 2021
2 parents ad8dd08 + 06b9649 commit f0f5b65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 189 deletions.
40 changes: 0 additions & 40 deletions packages/@ember/-internals/glimmer/lib/utils/managers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Owner } from '@ember/-internals/owner';
import { deprecate } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { ComponentManager } from '@glimmer/interfaces';
import {
componentCapabilities as glimmerComponentCapabilities,
Expand All @@ -17,41 +15,3 @@ export function setComponentManager(

export let componentCapabilities = glimmerComponentCapabilities;
export let modifierCapabilities = glimmerModifierCapabilities;

if (DEBUG) {
componentCapabilities = (version, options) => {
deprecate(
'Versions of component manager capabilities prior to 3.13 have been deprecated. You must update to the 3.13 capabilities.',
version === '3.13',
{
id: 'manager-capabilities.components-3-4',
url: 'https://deprecations.emberjs.com/v3.x#toc_manager-capabilities-components-3-4',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.26.0',
},
}
);

return glimmerComponentCapabilities(version, options);
};

modifierCapabilities = (version, options) => {
deprecate(
'Versions of modifier manager capabilities prior to 3.22 have been deprecated. You must update to the 3.22 capabilities.',
version === '3.22',
{
id: 'manager-capabilities.modifiers-3-13',
url: 'https://deprecations.emberjs.com/v3.x#toc_manager-capabilities-modifiers-3-13',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.26.0',
},
}
);

return glimmerModifierCapabilities(version, options);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { set, setProperties, computed, tracked } from '@ember/-internals/metal';
import { setComponentManager } from '@ember/-internals/glimmer';

const BasicComponentManager = EmberObject.extend({
capabilities: componentCapabilities('3.4'),
capabilities: componentCapabilities('3.13'),

createComponent(factory, args) {
return factory.create({ args });
Expand Down Expand Up @@ -39,7 +39,7 @@ class ComponentManagerTest extends RenderingTestCase {
super(...arguments);

InstrumentedComponentManager = EmberObject.extend({
capabilities: componentCapabilities('3.4', {
capabilities: componentCapabilities('3.13', {
destructor: true,
asyncLifecycleCallbacks: true,
}),
Expand Down Expand Up @@ -119,7 +119,7 @@ moduleFor(
['@test it can have no template context']() {
let ComponentClass = setComponentManager(() => {
return EmberObject.create({
capabilities: componentCapabilities('3.4'),
capabilities: componentCapabilities('3.13'),

createComponent() {
return null;
Expand Down Expand Up @@ -147,7 +147,7 @@ moduleFor(
class Base {}
setComponentManager(() => {
return EmberObject.create({
capabilities: componentCapabilities('3.4'),
capabilities: componentCapabilities('3.13'),

createComponent(Factory, args) {
return new Factory(args);
Expand Down Expand Up @@ -206,7 +206,7 @@ moduleFor(
let ComponentClass = setComponentManager(
() => {
return EmberObject.create({
capabilities: componentCapabilities('3.4'),
capabilities: componentCapabilities('3.13'),

createComponent(factory) {
return factory.create();
Expand Down Expand Up @@ -411,7 +411,7 @@ moduleFor(
let ComponentClass = setComponentManager(
() => {
return EmberObject.create({
capabilities: componentCapabilities('3.4', {
capabilities: componentCapabilities('3.13', {
destructor: true,
}),

Expand Down Expand Up @@ -461,7 +461,7 @@ moduleFor(
let ComponentClass = setComponentManager(
() => {
return EmberObject.create({
capabilities: componentCapabilities('3.4', {
capabilities: componentCapabilities('3.13', {
asyncLifecycleCallbacks: true,
}),

Expand Down Expand Up @@ -570,7 +570,7 @@ moduleFor(

assert.throws(() => {
this.render('{{foo-bar name=this.name}}', { name: 'world' });
}, /Custom component managers must have a `capabilities` property that is the result of calling the `capabilities\('3.4' \| '3.13'\)` \(imported via `import \{ capabilities \} from '@ember\/component';`\). /);
}, /Custom component managers must have a `capabilities` property that is the result of calling the `capabilities\('3.13'\)` \(imported via `import \{ capabilities \} from '@ember\/component';`\). /);

assert.verifySteps([]);
}
Expand Down Expand Up @@ -665,7 +665,7 @@ moduleFor(

['@test updating attributes triggers updateComponent and didUpdateComponent'](assert) {
let TestManager = EmberObject.extend({
capabilities: componentCapabilities('3.4', {
capabilities: componentCapabilities('3.13', {
destructor: true,
asyncLifecycleCallbacks: true,
}),
Expand Down Expand Up @@ -883,7 +883,7 @@ moduleFor(

assert.throws(() => {
this.render('<FooBar @name={{this.name}} />', { name: 'world' });
}, /Custom component managers must have a `capabilities` property that is the result of calling the `capabilities\('3.4' \| '3.13'\)` \(imported via `import \{ capabilities \} from '@ember\/component';`\). /);
}, /Custom component managers must have a `capabilities` property that is the result of calling the `capabilities\('3.13'\)` \(imported via `import \{ capabilities \} from '@ember\/component';`\). /);

assert.verifySteps([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,96 +360,12 @@ class ModifierManagerTest extends RenderingTestCase {

assert.throws(() => {
this.render('<h1 {{foo-bar}}>hello world</h1>');
}, /Custom modifier managers must have a `capabilities` property that is the result of calling the `capabilities\('3.13' \| '3.22'\)` \(imported via `import \{ capabilities \} from '@ember\/modifier';`\). /);
}, /Custom modifier managers must have a `capabilities` property that is the result of calling the `capabilities\('3.22'\)` \(imported via `import \{ capabilities \} from '@ember\/modifier';`\). /);

assert.verifySteps([]);
}
}

moduleFor(
'Basic Custom Modifier Manager: 3.13',
class extends ModifierManagerTest {
CustomModifierManager = class CustomModifierManager {
capabilities = modifierCapabilities('3.13');

constructor(owner) {
this.owner = owner;
}

createModifier(factory, args) {
// factory is the owner.factoryFor result
return factory.create(args);
}

installModifier(instance, element, args) {
instance.element = element;
let { positional, named } = args;
instance.didInsertElement(positional, named);
}

updateModifier(instance, args) {
let { positional, named } = args;
instance.didUpdate(positional, named);
}

destroyModifier(instance) {
instance.willDestroyElement();
}
};

'@test modifers consume all arguments'(assert) {
let insertCount = 0;
let updateCount = 0;

let ModifierClass = setModifierManager(
(owner) => {
return new this.CustomModifierManager(owner);
},
EmberObject.extend({
didInsertElement() {},
didUpdate() {},
willDestroyElement() {},
})
);

this.registerModifier(
'foo-bar',
ModifierClass.extend({
didInsertElement(_positional, named) {
insertCount++;

// consume qux
named.qux;
},

didUpdate(_positiona, named) {
updateCount++;

// consume qux
named.qux;
},
})
);

this.render('<h1 {{foo-bar bar=this.bar qux=this.qux}}>hello world</h1>', {
bar: 'bar',
qux: 'quz',
});

this.assertHTML(`<h1>hello world</h1>`);

assert.equal(insertCount, 1);
assert.equal(updateCount, 0);

runTask(() => set(this.context, 'bar', 'other bar'));
assert.equal(updateCount, 1);

runTask(() => set(this.context, 'qux', 'quuuuxxxxxx'));
assert.equal(updateCount, 2);
}
}
);

moduleFor(
'Basic Custom Modifier Manager: 3.22',
class extends ModifierManagerTest {
Expand Down Expand Up @@ -674,60 +590,6 @@ moduleFor(
return { isInteractive: false };
}

[`@test doesn't trigger lifecycle hooks when non-interactive: modifierCapabilities('3.13')`](
assert
) {
class CustomModifierManager {
capabilities = modifierCapabilities('3.13');

constructor(owner) {
this.owner = owner;
}

createModifier(factory, args) {
return factory.create(args);
}

installModifier(instance, element, args) {
instance.element = element;
let { positional, named } = args;
instance.didInsertElement(positional, named);
}

updateModifier(instance, args) {
let { positional, named } = args;
instance.didUpdate(positional, named);
}

destroyModifier(instance) {
instance.willDestroyElement();
}
}
let ModifierClass = setModifierManager(
(owner) => {
return new CustomModifierManager(owner);
},
EmberObject.extend({
didInsertElement() {
assert.ok(false);
},
didUpdate() {
assert.ok(false);
},
willDestroyElement() {
assert.ok(false);
},
})
);

this.registerModifier('foo-bar', ModifierClass);

this.render('<h1 {{foo-bar this.baz}}>hello world</h1>');
runTask(() => this.context.set('baz', 'Hello'));

this.assertHTML('<h1>hello world</h1>');
}

[`@test doesn't trigger lifecycle hooks when non-interactive: modifierCapabilities('3.22')`](
assert
) {
Expand Down

0 comments on commit f0f5b65

Please sign in to comment.