fix(view): remove dynamic components when the parent view is dehydrated
Also adds a bunch of unit tests for affected parts. Fixes #1201
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import {isBlank, isPresent} from 'angular2/src/facade/lang';
|
||||
import {AST} from 'angular2/change_detection';
|
||||
import {SetterFn} from 'angular2/src/reflection/types';
|
||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
@ -38,6 +39,14 @@ export class ElementBinder {
|
||||
this.distanceToParent = distanceToParent;
|
||||
this.propertySetters = propertySetters;
|
||||
}
|
||||
|
||||
hasStaticComponent() {
|
||||
return isPresent(this.componentId) && isPresent(this.nestedProtoView);
|
||||
}
|
||||
|
||||
hasDynamicComponent() {
|
||||
return isPresent(this.componentId) && isBlank(this.nestedProtoView);
|
||||
}
|
||||
}
|
||||
|
||||
export class Event {
|
||||
|
5
modules/angular2/src/render/dom/view/view.js
vendored
5
modules/angular2/src/render/dom/view/view.js
vendored
@ -165,6 +165,11 @@ export class RenderView {
|
||||
var cv = this.componentChildViews[i];
|
||||
if (isPresent(cv)) {
|
||||
cv.dehydrate();
|
||||
if (this.proto.elementBinders[i].hasDynamicComponent()) {
|
||||
ViewContainer.removeViewNodes(cv);
|
||||
this.lightDoms[i] = null;
|
||||
this.componentChildViews[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,6 @@ export class ViewFactory {
|
||||
} else {
|
||||
viewRootNodes = [rootElementClone];
|
||||
}
|
||||
|
||||
var binders = protoView.elementBinders;
|
||||
var boundTextNodes = [];
|
||||
var boundElements = ListWrapper.createFixedSize(binders.length);
|
||||
@ -133,7 +132,7 @@ export class ViewFactory {
|
||||
var element = boundElements[binderIdx];
|
||||
|
||||
// static child components
|
||||
if (isPresent(binder.componentId) && isPresent(binder.nestedProtoView)) {
|
||||
if (binder.hasStaticComponent()) {
|
||||
var childView = this._createView(binder.nestedProtoView);
|
||||
view.setComponentView(this._shadowDomStrategy, binderIdx, childView);
|
||||
}
|
||||
|
Reference in New Issue
Block a user