From eddec88849aac66247d05567b20fec9a30cb572d Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Fri, 8 Jan 2016 17:23:48 -0500 Subject: [PATCH] fix(compose): properly handle the created callback during dynamic composition --- src/compose.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/compose.js b/src/compose.js index 5eb2bd1..ad3b792 100644 --- a/src/compose.js +++ b/src/compose.js @@ -2,7 +2,7 @@ import {Container, inject} from 'aurelia-dependency-injection'; import {TaskQueue} from 'aurelia-task-queue'; import { CompositionEngine, ViewSlot, ViewResources, - customElement, bindable, noView + customElement, bindable, noView, View } from 'aurelia-templating'; import {DOM} from 'aurelia-pal'; @@ -55,11 +55,20 @@ export class Compose { this.currentViewModel = null; } + /** + * Invoked when the component has been created. + * + * @param owningView The view that this component was created inside of. + */ + created(owningView: View) { + this.owningView = owningView; + } + /** * Used to set the bindingContext. * - * @param {bindingContext} bindingContext The context in which the view model is executed in. - * @param {overrideContext} overrideContext The context in which the view model is executed in. + * @param bindingContext The context in which the view model is executed in. + * @param overrideContext The context in which the view model is executed in. */ bind(bindingContext, overrideContext) { this.bindingContext = bindingContext; @@ -154,6 +163,7 @@ function createInstruction(composer, instruction) { return Object.assign(instruction, { bindingContext: composer.bindingContext, overrideContext: composer.overrideContext, + owningView: composer.owningView, container: composer.container, viewSlot: composer.viewSlot, viewResources: composer.viewResources,