Skip to content

Commit

Permalink
[BUGFIX LTS] move LinkTo assertion into a method so LinkToExternal ca…
Browse files Browse the repository at this point in the history
…n override it

(cherry picked from commit 20aacf5)
  • Loading branch information
rwjblue authored and chancancode committed Mar 30, 2021
1 parent 1d53f7b commit fd1de5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/@ember/-internals/glimmer/lib/components/-link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,7 @@ const LinkComponent = EmberComponent.extend({
init() {
this._super(...arguments);

assert(
'You attempted to use the <LinkTo> component within a routeless engine, this is not supported. ' +
'If you are using the ember-engines addon, use the <LinkToExternal> component instead. ' +
'See https://ember-engines.com/docs/links for more info.',
!this._isEngine || this._engineMountPoint !== undefined
);
this.assertLinkToOrigin();

// Map desired event name to invoke function
let { eventName } = this;
Expand Down Expand Up @@ -636,6 +631,23 @@ const LinkComponent = EmberComponent.extend({
}
),

/**
* Method to assert that LinkTo is not used inside of a routeless engine. This method is
* overridden in ember-engines link-to-external component to just be a noop, since the
* link-to-external component extends the link-to component.
*
* @method assertLinkToOrigin
* @private
*/
assertLinkToOrigin() {
assert(
'You attempted to use the <LinkTo> component within a routeless engine, this is not supported. ' +
'If you are using the ember-engines addon, use the <LinkToExternal> component instead. ' +
'See https://ember-engines.com/docs/links for more info.',
!this._isEngine || this._engineMountPoint !== undefined
);
},

_isActive(routerState: RouterState): boolean {
if (this.loading) {
return false;
Expand Down
1 change: 1 addition & 0 deletions tests/docs/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module.exports = {
'arrayContentWillChange',
'assert',
'assertDestroyablesDestroyed',
'assertLinkToOrigin',
'assign',
'associateDestroyableChild',
'asyncEnd',
Expand Down

0 comments on commit fd1de5c

Please sign in to comment.