Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX LTS] move LinkTo assertion into a method so LinkToExternal can override #19477

Merged
merged 4 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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