Skip to content

Commit

Permalink
feat(view): reference creator container
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Apr 29, 2016
1 parent 873e489 commit 9431f53
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/view-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export class ViewFactory {
applyInstructions(containers, instructable, instruction, controllers, bindings, children, contentSelectors, partReplacements, resources);
}

view = new View(this, fragment, controllers, bindings, children, contentSelectors);
view = new View(container, this, fragment, controllers, bindings, children, contentSelectors);

//if iniated by an element behavior, let the behavior trigger this callback once it's done creating the element
if (!createInstruction.initiatedByBehavior) {
Expand Down
5 changes: 4 additions & 1 deletion src/view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Binding, createOverrideContext} from 'aurelia-binding';
import {Container} from 'aurelia-dependency-injection';

/**
* Represents a node in the view hierarchy.
Expand Down Expand Up @@ -27,13 +28,15 @@ interface ViewNode {
export class View {
/**
* Creates a View instance.
* @param container The container from which the view was created.
* @param viewFactory The factory that created this view.
* @param fragment The DOM fragement representing the view.
* @param controllers The controllers inside this view.
* @param bindings The bindings inside this view.
* @param children The children of this view.
*/
constructor(viewFactory: ViewFactory, fragment: DocumentFragment, controllers: Controller[], bindings: Binding[], children: ViewNode[], contentSelectors: Array<Object>) {
constructor(container: Container, viewFactory: ViewFactory, fragment: DocumentFragment, controllers: Controller[], bindings: Binding[], children: ViewNode[], contentSelectors: Array<Object>) {
this.container = container;
this.viewFactory = viewFactory;
this.resources = viewFactory.resources;
this.fragment = fragment;
Expand Down
3 changes: 2 additions & 1 deletion test/view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('View', () => {
let view;
let bindingContext = {};
let overrideContext = {};
let container = {};
let viewFactory = { resources: { _invokeHook: jasmine.createSpy('_invokeHook') } };
let fragment = {};
let controllers = [{ bind: jasmine.createSpy('bind'), unbind: jasmine.createSpy('unbind') }];
Expand All @@ -18,7 +19,7 @@ describe('View', () => {
}];
let children = [{ bind: jasmine.createSpy('bind'), unbind: jasmine.createSpy('unbind') }];
let contentSelectors = [];
view = new View(viewFactory, fragment, controllers, bindings, children, contentSelectors);
view = new View(container, viewFactory, fragment, controllers, bindings, children, contentSelectors);
view.bind(bindingContext, overrideContext);
expect(viewFactory.resources._invokeHook).toHaveBeenCalledWith('beforeBind', view);
expect(controllers[0].bind).toHaveBeenCalledWith(view);
Expand Down

0 comments on commit 9431f53

Please sign in to comment.