From 8c2334edd00eb5249df6ba43263dec07e09d2931 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Thu, 30 Jun 2016 15:01:56 -0400 Subject: [PATCH] feat(aurelia): make default root load relative to config module if defined --- src/aurelia.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/aurelia.js b/src/aurelia.js index 407ef879..3678d8b6 100644 --- a/src/aurelia.js +++ b/src/aurelia.js @@ -4,6 +4,7 @@ import {Container} from 'aurelia-dependency-injection'; import {Loader} from 'aurelia-loader'; import {BindingLanguage, ViewSlot, ViewResources, TemplatingEngine, CompositionTransaction} from 'aurelia-templating'; import {DOM, PLATFORM} from 'aurelia-pal'; +import {relativeToFile} from 'aurelia-path'; import {FrameworkConfiguration} from './framework-configuration'; function preventActionlessFormSubmit() { @@ -116,7 +117,7 @@ export class Aurelia { * @param applicationHost The DOM object that Aurelia will attach to. * @return Returns a Promise of the current Aurelia instance. */ - setRoot(root: string = 'app', applicationHost: string | Element = null): Promise { + setRoot(root: string = null, applicationHost: string | Element = null): Promise { let instruction = {}; if (this.root && this.root.viewModel && this.root.viewModel.router) { @@ -130,6 +131,14 @@ export class Aurelia { let transaction = this.container.get(CompositionTransaction); delete transaction.initialComposition; + if (!root) { + if (this.configModuleId) { + root = relativeToFile('./app', this.configModuleId); + } else { + root = 'app'; + } + } + instruction.viewModel = root; instruction.container = instruction.childContainer = this.container; instruction.viewSlot = this.hostSlot;