-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with LinkTo and LinkToExternal on Ember 3.24.0.
Also includes a work around for 3.24.0 (which should be fixed in Ember 3.24.1 once released).
- Loading branch information
Showing
4 changed files
with
1,320 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 28 additions & 12 deletions
40
packages/ember-engines/addon/components/link-to-external.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
import LinkComponent from '@ember/routing/link-component'; | ||
import { getOwner } from '@ember/application'; | ||
import { set, get } from '@ember/object'; | ||
import { macroCondition, dependencySatisfies } from '@embroider/macros'; | ||
|
||
export default LinkComponent.extend({ | ||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
let LinkToExternal; | ||
|
||
const owner = getOwner(this); | ||
if (macroCondition(dependencySatisfies('ember-source', '> 3.24.0-alpha.1'))) { | ||
LinkToExternal = class LinkToExternal extends LinkComponent { | ||
_namespaceRoute(targetRouteName) { | ||
const owner = getOwner(this); | ||
const externalRoute = owner._getExternalRoute(targetRouteName); | ||
|
||
if (owner.mountPoint) { | ||
// https://emberjs.github.io/rfcs/0459-angle-bracket-built-in-components.html | ||
const routeKey = 'targetRouteName' in this ? 'targetRouteName' : 'route'; | ||
const routeName = get(this, routeKey); | ||
const externalRoute = owner._getExternalRoute(routeName); | ||
set(this, routeKey, externalRoute); | ||
return externalRoute; | ||
} | ||
} | ||
}); | ||
}; | ||
} else { | ||
LinkToExternal = LinkComponent.extend({ | ||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
|
||
const owner = getOwner(this); | ||
|
||
if (owner.mountPoint) { | ||
// https://emberjs.github.io/rfcs/0459-angle-bracket-built-in-components.html | ||
const routeKey = 'targetRouteName' in this ? 'targetRouteName' : 'route'; | ||
const routeName = get(this, routeKey); | ||
const externalRoute = owner._getExternalRoute(routeName); | ||
set(this, routeKey, externalRoute); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
export default LinkToExternal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.