diff --git a/src/link.ts b/src/link.ts index 82afda7a..46887fdb 100644 --- a/src/link.ts +++ b/src/link.ts @@ -1,6 +1,5 @@ import { tracked } from '@glimmer/tracking'; import { assert } from '@ember/debug'; -import { action } from '@ember/object'; import { BEHAVIOR, type Behavior } from './-behavior.ts'; import { getOwner, setOwner } from './-owner.ts'; @@ -208,9 +207,8 @@ export default class Link { /** * Transition into the target route. */ - @action // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents - transitionTo(event?: Event | unknown): Transition | undefined { + transitionTo = (event?: Event | unknown): Transition | undefined => { if (!this.canOpen(event)) { return; } @@ -220,15 +218,14 @@ export default class Link { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return this._linkManager.router.transitionTo(...this._routeArgs); - } + }; /** * Transition into the target route while replacing the current URL, if * possible. */ - @action // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents - replaceWith(event?: Event | unknown): Transition | undefined { + replaceWith = (event?: Event | unknown): Transition | undefined => { if (!this.canOpen(event)) { return; } @@ -238,11 +235,10 @@ export default class Link { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return this._linkManager.router.replaceWith(...this._routeArgs); - } + }; - @action // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents - open(event?: Event | unknown): Transition | undefined { + open = (event?: Event | unknown): Transition | undefined => { // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition const method = this.behavior.open ?? 'transition'; @@ -251,5 +247,5 @@ export default class Link { } return this.transitionTo(event); - } + }; } diff --git a/src/test-support/test-link.ts b/src/test-support/test-link.ts index 055c44d0..25566573 100644 --- a/src/test-support/test-link.ts +++ b/src/test-support/test-link.ts @@ -1,7 +1,7 @@ import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; import { guidFor } from '@ember/object/internals'; +import { preventDefault } from '../-behavior.ts'; import Link from '../link.ts'; import type Transition from '@ember/routing/transition'; @@ -80,8 +80,8 @@ export default class TestLink extends Link { return this.routeName; } - @action - transitionTo(event?: Event): Transition { + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents + transitionTo = (event?: Event | unknown): Transition => { this._preventTransitionOut(event); // Fire both the `onTransitionTo` event used for testing, as well as the @@ -90,10 +90,10 @@ export default class TestLink extends Link { this.onTransitionTo?.(); return this._createDummyTransition(); - } + }; - @action - replaceWith(event?: Event): Transition { + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents + replaceWith = (event?: Event | unknown): Transition => { this._preventTransitionOut(event); // Fire both the `onReplaceWith` event used for testing, as well as the @@ -102,10 +102,10 @@ export default class TestLink extends Link { this.onReplaceWith?.(); return this._createDummyTransition(); - } + }; - @action - open(event?: Event): Transition | undefined { + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents + open = (event?: Event | unknown): Transition | undefined => { const method = this.behavior.open; if (method === 'replace') { @@ -113,11 +113,12 @@ export default class TestLink extends Link { } return this.transitionTo(event); - } + }; - private _preventTransitionOut(event?: Event) { + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents + private _preventTransitionOut(event?: Event | unknown) { // Make sure we don't transition out of the testing page - event?.preventDefault(); + preventDefault(event); } private _createDummyTransition(): Transition {