Skip to content

Commit 10708ca

Browse files
fix(aurelia): enable multiple calls to setRoot
1 parent f458a19 commit 10708ca

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/aurelia.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export class Aurelia {
8686
use:Plugins;
8787

8888
constructor(loader?:Loader, container?:Container, resources?:ViewResources){
89+
this.hostConfigured = false;
90+
this.host = null;
8991
this.resourcesToLoad = {};
9092
this.preStartTasks = [];
9193
this.postStartTasks = [];
@@ -278,8 +280,7 @@ export class Aurelia {
278280
compositionEngine = this.container.get(CompositionEngine);
279281
instruction.viewModel = root;
280282
instruction.container = instruction.childContainer = this.container;
281-
instruction.viewSlot = new ViewSlot(this.host, true);
282-
instruction.viewSlot.transformChildNodesIntoView();
283+
instruction.viewSlot = this.hostSlot;
283284
instruction.host = this.host;
284285

285286
return compositionEngine.compose(instruction).then(root => {
@@ -291,6 +292,10 @@ export class Aurelia {
291292
}
292293

293294
_configureHost(applicationHost){
295+
if(this.hostConfigured){
296+
return;
297+
}
298+
294299
applicationHost = applicationHost || this.host;
295300

296301
if (!applicationHost || typeof applicationHost == 'string') {
@@ -299,7 +304,10 @@ export class Aurelia {
299304
this.host = applicationHost;
300305
}
301306

307+
this.hostConfigured = true;
302308
this.host.aurelia = this;
309+
this.hostSlot = new ViewSlot(this.host, true);
310+
this.hostSlot.transformChildNodesIntoView();
303311
this.container.registerInstance(DOMBoundary, this.host);
304312
}
305313

0 commit comments

Comments
 (0)