Skip to content

Commit

Permalink
Merge pull request #165 from 2hu12/patch-1
Browse files Browse the repository at this point in the history
Use the "app" argument if available
  • Loading branch information
nlfurniss authored Jun 25, 2019
2 parents 7fad766 + 787d4b7 commit 8dac788
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ module.exports = {
}
},

included() {
included(app) {
this._super.included.apply(this, arguments);

let app;

// If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
// use that.
if (typeof this._findHost === 'function') {
app = this._findHost();
} else {
// Otherwise, we'll use this implementation borrowed from the _findHost()
// method in ember-cli.
let current = this;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
// The app argument passed to included is the host app or parent addon.
// And the addon has a `import` api exposed since ember-cli/ember-cli#5877.
// If the `app.import` is available we can just use that.
if (typeof app.import !== 'function') {
// If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
// use that.
if (typeof this._findHost === 'function') {
app = this._findHost();
} else {
// Otherwise, we'll use this implementation borrowed from the _findHost()
// method in ember-cli.
let current = this;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
}
}

let options = app.options.emberHighCharts || { includeHighCharts: true };
Expand Down

0 comments on commit 8dac788

Please sign in to comment.