Skip to content

Commit

Permalink
Merge pull request intercom#33 from ilucin/master
Browse files Browse the repository at this point in the history
Remove deprecation warnings in newer Ember versions
  • Loading branch information
GavinJoyce committed Apr 4, 2016
2 parents 3bca276 + 768b05f commit 231400d
Show file tree
Hide file tree
Showing 3 changed files with 10 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
@@ -1,8 +1,9 @@
import Em from 'ember';
import getOwner from 'ember-getowner-polyfill';

export default Em.Helper.extend({
compute(params) {
let router = this.container.lookup('router:main');
let router = getOwner(this).lookup('router:main');
if(router === undefined || router.router === undefined) {
return;
}
Expand Down
7 changes: 6 additions & 1 deletion app/instance-initializers/ember-href-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ function _getNormalisedRootUrl(router) {
return rootURL;
}

function _lookupRouter(applicationInstance) {
const container = 'lookup' in applicationInstance ? applicationInstance : applicationInstance.container;
return container.lookup('router:main');
}

export default {
name: 'ember-href-to',
initialize: function(applicationInstance) {
let router = applicationInstance.container.lookup('router:main');
let router = _lookupRouter(applicationInstance);
let rootURL = _getNormalisedRootUrl(router);
let $body = Em.$(document.body);

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.0.0"
"ember-cli-babel": "^5.0.0",
"ember-getowner-polyfill": "^1.0.1"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down

0 comments on commit 231400d

Please sign in to comment.