Skip to content

Commit

Permalink
Restore compatibility with Ember Engines previously fixed in #315
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemelia committed Jan 29, 2022
1 parent 45ee190 commit 585b13d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion addon/instance-initializers/add-modals-container.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getDestinationElementIdFromConfig } from 'ember-modal-dialog/utils/config-utils';
import { getOwner } from '@ember/application';

let hasDOM = typeof document !== 'undefined';

Expand All @@ -24,5 +25,11 @@ export default function (instance) {
let config = instance.resolveRegistration('config:environment');
let modalContainerElId = getDestinationElementIdFromConfig(config);

appendContainerElement(instance.rootElement, modalContainerElId);
// As there is only a single `Router` across the whole app, which is owned
// by the root `Application`, this reliably finds the root `Application`
// from an `Application` or `Engine`.
// eslint-disable-next-line ember/no-private-routing-service
let app = getOwner(instance.lookup('router:main'));

appendContainerElement(app.rootElement, modalContainerElId);
}

0 comments on commit 585b13d

Please sign in to comment.