Skip to content

Commit

Permalink
Deprecate positional arguments for link-to components
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed May 14, 2021
1 parent 4c11096 commit f1e5f37
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
13 changes: 12 additions & 1 deletion addon/components/bs-link-to.js
Expand Up @@ -2,7 +2,7 @@
import Component from '@ember/component';
import { tagName } from '@ember-decorators/component';
import { inject as service } from '@ember/service';
import { assert } from '@ember/debug';
import { assert, deprecate } from '@ember/debug';
import ComponentChild from '../mixins/component-child';
import { dependentKeyCompat } from '@ember/object/compat';

Expand Down Expand Up @@ -70,6 +70,17 @@ class LinkComponent extends Component.extend(ComponentChild) {
return;
}

deprecate(
`Positional arguments for ember-bootstrap's link-to components are deprecated. Switch to angle bracket invocation and named arguments.`,
false,
{
id: `ember-bootstrap.link-to.positional-args`,
until: '5.0.0',
since: '4.7.0',
for: 'ember-bootstrap',
}
);

params = params.slice();

// taken from original Ember.LnkComponent
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/components/bs-dropdown/menu/link-to-test.js
Expand Up @@ -7,6 +7,8 @@ import setupNoDeprecations from '../../../../helpers/setup-no-deprecations';

module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
setupRenderingTest(hooks);
setupNoDeprecations(hooks);

hooks.beforeEach(function () {
this.owner.setupRouter();
});
Expand Down Expand Up @@ -39,7 +41,10 @@ module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
assert.dom('a.dropdown-item').exists({ count: 1 }, 'renders as plain element with dropdown item class');
});

module('positional params', function () {
module('positional params', function (hooks) {
hooks.afterEach(function (assert) {
assert.deprecationsInclude(`Positional arguments for ember-bootstrap's link-to components are deprecated.`);
});
test('simple route link', async function (assert) {
await render(hbs`
<BsDropdown as |dd|>
Expand Down Expand Up @@ -83,9 +88,7 @@ module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
});
});

module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);

module('<LinkTo> properties', function () {
test('simple route link', async function (assert) {
await render(hbs`
<BsDropdown as |dd|>
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/components/bs-nav/link-to-test.js
Expand Up @@ -7,11 +7,15 @@ import { testNotBS3 } from '../../../helpers/bootstrap';

module('Integration | Component | bs-nav/link-to', function (hooks) {
setupRenderingTest(hooks);
setupNoDeprecations(hooks);
hooks.beforeEach(function () {
this.owner.setupRouter();
});

module('positional params', function () {
module('positional params', function (hooks) {
hooks.afterEach(function (assert) {
assert.deprecationsInclude(`Positional arguments for ember-bootstrap's link-to components are deprecated.`);
});
test('simple route link', async function (assert) {
await render(hbs`
<BsNav as |nav|>
Expand Down Expand Up @@ -62,9 +66,7 @@ module('Integration | Component | bs-nav/link-to', function (hooks) {
});
});

module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);

module('<LinkTo> properties', function () {
test('simple route link', async function (assert) {
await render(hbs`
<BsNav as |nav|>
Expand Down

0 comments on commit f1e5f37

Please sign in to comment.