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

Remove deprecated disabledWhen #19624

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 0 additions & 6 deletions packages/@ember/-internals/glimmer/lib/components/-link-to.ts
Expand Up @@ -879,12 +879,6 @@ const LinkComponent = EmberComponent.extend({
loadingHref: '#',

didReceiveAttrs() {
let { disabledWhen } = this;

if (disabledWhen !== undefined) {
this.set('disabled', disabledWhen);
}

let { params } = this;

if (!params || params.length === 0) {
Expand Down
35 changes: 0 additions & 35 deletions packages/@ember/-internals/glimmer/lib/components/link-to.ts
Expand Up @@ -614,32 +614,13 @@ if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
});
}

// @disabledWhen
{
let superIsSupportedArgument = prototype['isSupportedArgument'];

Object.defineProperty(prototype, 'isSupportedArgument', {
configurable: true,
enumerable: false,
value: function isSupportedArgument(this: LinkTo, name: string): boolean {
if (this.modernized) {
if (name === 'disabledWhen') {
deprecate(
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. ' +
'Use the `@disabled` argument instead.',
false,
{
id: 'ember.link-to.disabled-when',
for: 'ember-source',
since: {},
until: '4.0.0',
}
);

return true;
}
}

return superIsSupportedArgument.call(this, name);
},
});
nlfurniss marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -657,22 +638,6 @@ if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
configurable: true,
enumerable: false,
get: function isDisabled(this: LinkTo): boolean {
if ('disabledWhen' in this.args.named) {
deprecate(
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. ' +
'Use the `@disabled` argument instead.',
false,
{
id: 'ember.link-to.disabled-when',
for: 'ember-source',
since: {},
until: '4.0.0',
}
);

return Boolean(this.named('disabledWhen'));
}

return superGetter.call(this);
},
});
nlfurniss marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Expand Up @@ -106,64 +106,6 @@ moduleFor(
assert.strictEqual(this.$('#about-link').attr('href'), null, 'there is no href attribute');
}

async [`@test [DEPRECATED] it applies a 'disabled' class when disabledWhen`](assert) {
this.addTemplate(
'index',
`
<LinkTo id="about-link-static" @route="about" @disabledWhen="truthy">About</LinkTo>
<LinkTo id="about-link-dynamic" @route="about" @disabledWhen={{this.dynamicDisabledWhen}}>About</LinkTo>
`
);

let controller;

this.add(
'controller:index',
class extends Controller {
constructor(...args) {
super(...args);
controller = this;
}

dynamicDisabledWhen = true;
}
);

await expectDeprecationAsync(
() => this.visit('/'),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

assert.equal(
this.$('#about-link-static.disabled').length,
1,
'The static link is disabled when its disabledWhen is true'
);
assert.equal(
this.$('#about-link-dynamic.disabled').length,
1,
'The dynamic link is disabled when its disabledWhen is true'
);

expectDeprecation(
() => runTask(() => controller.set('dynamicDisabledWhen', false)),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

assert.equal(
this.$('#about-link-static.disabled').length,
1,
'The static link is disabled when its disabledWhen is true'
);
assert.strictEqual(
this.$('#about-link-dynamic.disabled').length,
0,
'The dynamic link is re-enabled when its disabledWhen becomes false'
);
}

async [`@test it applies a 'disabled' class when disabled`](assert) {
this.addTemplate(
'index',
Expand Down Expand Up @@ -343,27 +285,6 @@ moduleFor(
);
}

async [`@test [DEPRECATED] it does not respond to clicks when disabledWhen`](assert) {
this.addTemplate(
'index',
`<LinkTo id="about-link" @route="about" @disabledWhen={{true}}>About</LinkTo>`
);

await expectDeprecationAsync(
() => this.visit('/'),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

await expectDeprecationAsync(
() => this.click('#about-link'),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

assert.strictEqual(this.$('h3.about').length, 0, 'Transitioning did not occur');
}

async [`@test it does not respond to clicks when disabled`](assert) {
this.addTemplate(
'index',
Expand Down Expand Up @@ -410,7 +331,7 @@ moduleFor(
assert.equal(
this.$('h3.about').length,
1,
'Transitioning did occur when disabledWhen became false'
'Transitioning did occur when disabled became false'
nlfurniss marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down
Expand Up @@ -111,64 +111,6 @@ moduleFor(
);
}

async [`@test [DEPRECATED] it applies a 'disabled' class when disabledWhen`](assert) {
this.addTemplate(
'index',
`
<div id="about-link-static">{{#link-to route="about" disabledWhen="truthy"}}About{{/link-to}}</div>
<div id="about-link-dynamic">{{#link-to route="about" disabledWhen=this.dynamicDisabledWhen}}About{{/link-to}}</div>
`
);

let controller;

this.add(
'controller:index',
class extends Controller {
constructor(...args) {
super(...args);
controller = this;
}

dynamicDisabledWhen = true;
}
);

await expectDeprecationAsync(
() => this.visit('/'),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

assert.equal(
this.$('#about-link-static > a.disabled').length,
1,
'The static link is disabled when its disabledWhen is true'
);
assert.equal(
this.$('#about-link-dynamic > a.disabled').length,
1,
'The dynamic link is disabled when its disabledWhen is true'
);

expectDeprecation(
() => runTask(() => controller.set('dynamicDisabledWhen', false)),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

assert.equal(
this.$('#about-link-static > a.disabled').length,
1,
'The static link is disabled when its disabledWhen is true'
);
assert.strictEqual(
this.$('#about-link-dynamic > a.disabled').length,
0,
'The dynamic link is re-enabled when its disabledWhen becomes false'
);
}

async [`@test it applies a 'disabled' class when disabled`](assert) {
this.addTemplate(
'index',
Expand Down Expand Up @@ -210,7 +152,7 @@ moduleFor(
assert.equal(
this.$('#about-link-static > a.disabled').length,
1,
'The static link is disabled when its disabledWhen is true'
'The static link is disabled when its disabled is true'
);
assert.strictEqual(
this.$('#about-link-dynamic > a.disabled').length,
Expand Down Expand Up @@ -355,27 +297,6 @@ moduleFor(
);
}

async [`@test [DEPRECATED] it does not respond to clicks when disabledWhen`](assert) {
this.addTemplate(
'index',
`<div id="about-link">{{#link-to route="about" disabledWhen=true}}About{{/link-to}}</div>`
);

await expectDeprecationAsync(
() => this.visit('/'),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

await expectDeprecationAsync(
() => this.click('#about-link > a'),
'Passing the `@disabledWhen` argument to <LinkTo> is deprecated. Use the `@disabled` argument instead.',
EMBER_MODERNIZED_BUILT_IN_COMPONENTS
);

assert.strictEqual(this.$('h3.about').length, 0, 'Transitioning did not occur');
}

async [`@test it does not respond to clicks when disabled`](assert) {
this.addTemplate(
'index',
Expand Down Expand Up @@ -422,7 +343,7 @@ moduleFor(
assert.equal(
this.$('h3.about').length,
1,
'Transitioning did occur when disabledWhen became false'
'Transitioning did occur when disabled became false'
);
}

Expand Down