Skip to content

Commit

Permalink
Use _routerMicrolib instead of router when available
Browse files Browse the repository at this point in the history
  • Loading branch information
m-basov committed May 2, 2017
1 parent 4ccfa07 commit 79c33ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion addon/helpers/href-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const { getOwner } = Em;

function hrefTo(context, targetRouteName, ...rest) {
let router = getOwner(context).lookup('router:main');
if (router === undefined || router.router === undefined) {
if (router === undefined ||
(router._routerMicrolib === undefined && router.router === undefined)) {
return;
}

Expand Down
6 changes: 4 additions & 2 deletions addon/href-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export default class {
handle() {
let router = this._getRouter();
let urlWithoutRoot = this.getUrlWithoutRoot();
let routerMicrolib = router._routerMicrolib || router.router;

router.handleURL(urlWithoutRoot);
router.router.updateURL(urlWithoutRoot);
routerMicrolib.updateURL(urlWithoutRoot);
this.event.preventDefault();
}

Expand Down Expand Up @@ -78,8 +79,9 @@ export default class {
let rootUrl = this._getRootUrl();
let isInternal = url.indexOf(rootUrl) === 0;
let urlWithoutRoot = this.getUrlWithoutRoot();
let routerMicrolib = router._routerMicrolib || router.router;

didRecognize = isInternal && router.router.recognizer.recognize(urlWithoutRoot);
didRecognize = isInternal && routerMicrolib.recognizer.recognize(urlWithoutRoot);
}

return didRecognize;
Expand Down

0 comments on commit 79c33ce

Please sign in to comment.