Skip to content

Commit

Permalink
Merge pull request #137 from intercom/gj/conditional-on
Browse files Browse the repository at this point in the history
don't subscribe to `routeDidChange` if the router service is a mock
  • Loading branch information
GavinJoyce committed Sep 29, 2020
2 parents 363cd30 + dc53100 commit b1c544f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion addon/helpers/href-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default class HrefToHelper extends Helper {

init() {
super.init();
this.router.on('routeDidChange', this.recompute.bind(this));

if (this.router && this.router.on) { // skip if the router service is mocked
this.router.on("routeDidChange", this.recompute.bind(this));
}
}

compute(params, namedArgs) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-href-to",
"version": "4.0.0",
"version": "4.1.0",
"description": "A lightweight alternative to `{{link-to}}`",
"scripts": {
"lint:hbs": "ember-template-lint .",
Expand Down

0 comments on commit b1c544f

Please sign in to comment.