From 92750b9f8b32cd4f11855bf19836d7da2cd7ba00 Mon Sep 17 00:00:00 2001 From: Nathaniel Furniss Date: Tue, 13 Jul 2021 15:06:01 -0700 Subject: [PATCH] Remove deprecated disabledWhen --- .../glimmer/lib/components/-link-to.ts | 6 -- .../glimmer/lib/components/link-to.ts | 64 -------------- .../components/link-to/routing-angle-test.js | 81 +----------------- .../components/link-to/routing-curly-test.js | 83 +------------------ 4 files changed, 3 insertions(+), 231 deletions(-) diff --git a/packages/@ember/-internals/glimmer/lib/components/-link-to.ts b/packages/@ember/-internals/glimmer/lib/components/-link-to.ts index 642eeb64605..f0a8e651e13 100644 --- a/packages/@ember/-internals/glimmer/lib/components/-link-to.ts +++ b/packages/@ember/-internals/glimmer/lib/components/-link-to.ts @@ -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) { diff --git a/packages/@ember/-internals/glimmer/lib/components/link-to.ts b/packages/@ember/-internals/glimmer/lib/components/link-to.ts index a139ba18c80..3bb0b105281 100644 --- a/packages/@ember/-internals/glimmer/lib/components/link-to.ts +++ b/packages/@ember/-internals/glimmer/lib/components/link-to.ts @@ -614,70 +614,6 @@ 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 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); - }, - }); - - let superDescriptor = descriptorFor(prototype, 'isDisabled'); - - assert( - `[BUG] expecting isDisabled to be a getter on `, - superDescriptor && typeof superDescriptor.get === 'function' - ); - - let superGetter = superDescriptor.get as (this: LinkTo) => boolean; - - Object.defineProperty(prototype, 'isDisabled', { - configurable: true, - enumerable: false, - get: function isDisabled(this: LinkTo): boolean { - if ('disabledWhen' in this.args.named) { - deprecate( - 'Passing the `@disabledWhen` argument to 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); - }, - }); - } - // QP { let superModelsDescriptor = descriptorFor(prototype, 'models'); diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js index fa7e4c22561..f1d1cfc863c 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js @@ -147,64 +147,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', - ` - About - About - ` - ); - - 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 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 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', @@ -384,27 +326,6 @@ moduleFor( ); } - async [`@test [DEPRECATED] it does not respond to clicks when disabledWhen`](assert) { - this.addTemplate( - 'index', - `About` - ); - - await expectDeprecationAsync( - () => this.visit('/'), - 'Passing the `@disabledWhen` argument to is deprecated. Use the `@disabled` argument instead.', - EMBER_MODERNIZED_BUILT_IN_COMPONENTS - ); - - await expectDeprecationAsync( - () => this.click('#about-link'), - 'Passing the `@disabledWhen` argument to 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', @@ -451,7 +372,7 @@ moduleFor( assert.equal( this.$('h3.about').length, 1, - 'Transitioning did occur when disabledWhen became false' + 'Transitioning did occur when disabled became false' ); } diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js index 2ecf5ae4cf0..eb12ae9e343 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js @@ -152,64 +152,6 @@ moduleFor( ); } - async [`@test [DEPRECATED] it applies a 'disabled' class when disabledWhen`](assert) { - this.addTemplate( - 'index', - ` - - - ` - ); - - 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 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 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', @@ -251,7 +193,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, @@ -396,27 +338,6 @@ moduleFor( ); } - async [`@test [DEPRECATED] it does not respond to clicks when disabledWhen`](assert) { - this.addTemplate( - 'index', - `` - ); - - await expectDeprecationAsync( - () => this.visit('/'), - 'Passing the `@disabledWhen` argument to is deprecated. Use the `@disabled` argument instead.', - EMBER_MODERNIZED_BUILT_IN_COMPONENTS - ); - - await expectDeprecationAsync( - () => this.click('#about-link > a'), - 'Passing the `@disabledWhen` argument to 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', @@ -463,7 +384,7 @@ moduleFor( assert.equal( this.$('h3.about').length, 1, - 'Transitioning did occur when disabledWhen became false' + 'Transitioning did occur when disabled became false' ); }