fix(render): return views when destroyed in ViewContainer

Closes #1316
This commit is contained in:
Tobias Bosch 2015-04-27 14:07:08 -07:00
parent 1b2754dacd
commit 6fcd3709cf
2 changed files with 14 additions and 1 deletions

View File

@ -180,7 +180,9 @@ export class RenderViewHydrator {
_viewContainerDehydrateRecurse(viewContainer) {
for (var i=0; i<viewContainer.views.length; i++) {
this._viewDehydrateRecurse(viewContainer.views[i]);
var view = viewContainer.views[i];
this._viewDehydrateRecurse(view);
this._viewFactory.returnView(view);
}
viewContainer.clear();
}

View File

@ -223,6 +223,17 @@ export function main() {
expect(viewFactory.spy('returnView')).toHaveBeenCalledWith(shadowView);
});
it('should clear views in ViewContainers', () => {
createAndHydrate(null, null);
var vc = hostView.getOrCreateViewContainer(0);
var childView = createEmptyView();
vc.insert(childView);
dehydrate(hostView);
expect(viewFactory.spy('returnView')).toHaveBeenCalledWith(childView);
});
it('should clear imperatively added child components', () => {
var shadowView = createEmptyView();
createAndHydrate(createProtoView(), shadowView);