From 37dc947297bb6b630e3442cd93451ab2a88a791b Mon Sep 17 00:00:00 2001 From: Ivan Lucin Date: Thu, 31 Mar 2016 11:48:45 +0200 Subject: [PATCH 1/2] Fix router lookup to avoid deprecations in ember >= 2 --- app/instance-initializers/ember-href-to.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/instance-initializers/ember-href-to.js b/app/instance-initializers/ember-href-to.js index a5633d1..c5425c0 100644 --- a/app/instance-initializers/ember-href-to.js +++ b/app/instance-initializers/ember-href-to.js @@ -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); From 768b05f6cf5fe56dcda580b1312b7715c2552a0a Mon Sep 17 00:00:00 2001 From: Ivan Lucin Date: Thu, 31 Mar 2016 11:49:35 +0200 Subject: [PATCH 2/2] Add getOwner polyfill to remove deprecations in ember >= 2.3 --- addon/helpers/href-to.js | 3 ++- package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addon/helpers/href-to.js b/addon/helpers/href-to.js index 7136942..b131ccb 100644 --- a/addon/helpers/href-to.js +++ b/addon/helpers/href-to.js @@ -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; } diff --git a/package.json b/package.json index b23df5d..80f660f 100644 --- a/package.json +++ b/package.json @@ -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"