Skip to content

Commit

Permalink
Merge pull request #19477 from hmajoros/hmajoros/LinkToFix
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Mar 29, 2021
2 parents 4b1288c + 62e7b92 commit 20aacf5
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
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
Expand Up @@ -92,6 +92,7 @@ module.exports = {
'arrayContentWillChange',
'assert',
'assertDestroyablesDestroyed',
'assertLinkToOrigin',
'assign',
'associateDestroyableChild',
'asyncEnd',
Expand Down

0 comments on commit 20aacf5

Please sign in to comment.