refactor(render): create and store render ProtoViewRef in every app ProtoView
Needed to change Renderer.mergeChildComponentProtoViews to not create new ProtoViews to be able to deal with cyclic references. This commit is part of using the new render layer in Angular.
This commit is contained in:
@ -1,12 +1,8 @@
|
||||
import {AST} from 'angular2/change_detection';
|
||||
import {SetterFn} from 'angular2/src/reflection/types';
|
||||
import {isPresent, isBlank, BaseException} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import * as protoViewModule from './proto_view';
|
||||
|
||||
/**
|
||||
* Note: Code that uses this class assumes that is immutable!
|
||||
*/
|
||||
export class ElementBinder {
|
||||
contentTagSelector: string;
|
||||
textNodeIndices: List<number>;
|
||||
@ -39,24 +35,4 @@ export class ElementBinder {
|
||||
this.distanceToParent = distanceToParent;
|
||||
this.propertySetters = propertySetters;
|
||||
}
|
||||
|
||||
mergeChildComponentProtoViews(protoViews:List<protoViewModule.ProtoView>, target:List<protoViewModule.ProtoView>):ElementBinder {
|
||||
var nestedProtoView;
|
||||
if (isPresent(this.componentId)) {
|
||||
nestedProtoView = ListWrapper.removeAt(protoViews, 0);
|
||||
} else if (isPresent(this.nestedProtoView)) {
|
||||
nestedProtoView = this.nestedProtoView.mergeChildComponentProtoViews(protoViews, target);
|
||||
}
|
||||
return new ElementBinder({
|
||||
parentIndex: this.parentIndex,
|
||||
textNodeIndices: this.textNodeIndices,
|
||||
contentTagSelector: this.contentTagSelector,
|
||||
nestedProtoView: nestedProtoView,
|
||||
componentId: this.componentId,
|
||||
eventLocals: this.eventLocals,
|
||||
eventNames: this.eventNames,
|
||||
distanceToParent: this.distanceToParent,
|
||||
propertySetters: this.propertySetters
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ import {List, Map, ListWrapper, MapWrapper} from 'angular2/src/facade/collection
|
||||
import {ElementBinder} from './element_binder';
|
||||
import {NG_BINDING_CLASS} from '../util';
|
||||
|
||||
/**
|
||||
* Note: Code that uses this class assumes that is immutable!
|
||||
*/
|
||||
export class ProtoView {
|
||||
element;
|
||||
elementBinders:List<ElementBinder>;
|
||||
@ -28,22 +25,14 @@ export class ProtoView {
|
||||
this.rootBindingOffset = (isPresent(this.element) && DOM.hasClass(this.element, NG_BINDING_CLASS)) ? 1 : 0;
|
||||
}
|
||||
|
||||
mergeChildComponentProtoViews(protoViews:List<ProtoView>, target:List<ProtoView>):ProtoView {
|
||||
var elementBinders = ListWrapper.createFixedSize(this.elementBinders.length);
|
||||
mergeChildComponentProtoViews(componentProtoViews:List<ProtoView>) {
|
||||
var componentProtoViewIndex = 0;
|
||||
for (var i=0; i<this.elementBinders.length; i++) {
|
||||
var eb = this.elementBinders[i];
|
||||
if (isPresent(eb.componentId) || isPresent(eb.nestedProtoView)) {
|
||||
elementBinders[i] = eb.mergeChildComponentProtoViews(protoViews, target);
|
||||
} else {
|
||||
elementBinders[i] = eb;
|
||||
if (isPresent(eb.componentId)) {
|
||||
eb.nestedProtoView = componentProtoViews[componentProtoViewIndex];
|
||||
componentProtoViewIndex++;
|
||||
}
|
||||
}
|
||||
var result = new ProtoView({
|
||||
elementBinders: elementBinders,
|
||||
element: this.element,
|
||||
isRootView: this.isRootView
|
||||
});
|
||||
ListWrapper.insert(target, 0, result);
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user