2015-03-23 14:10:55 -07:00
|
|
|
import {isPresent} from 'angular2/src/facade/lang';
|
|
|
|
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
|
|
|
|
|
|
|
|
|
import {List, Map, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
|
|
|
|
|
|
|
|
|
import {ElementBinder} from './element_binder';
|
|
|
|
|
import {NG_BINDING_CLASS} from '../util';
|
|
|
|
|
|
2015-05-06 11:22:28 -07:00
|
|
|
export class DomProtoView {
|
2015-03-23 14:10:55 -07:00
|
|
|
element;
|
|
|
|
|
elementBinders:List<ElementBinder>;
|
|
|
|
|
isTemplateElement:boolean;
|
|
|
|
|
rootBindingOffset:int;
|
2015-04-20 11:34:53 -07:00
|
|
|
imperativeRendererId:string;
|
2015-03-23 14:10:55 -07:00
|
|
|
|
|
|
|
|
constructor({
|
|
|
|
|
elementBinders,
|
2015-04-20 11:34:53 -07:00
|
|
|
element,
|
|
|
|
|
imperativeRendererId
|
2015-03-23 14:10:55 -07:00
|
|
|
}) {
|
|
|
|
|
this.element = element;
|
|
|
|
|
this.elementBinders = elementBinders;
|
2015-04-20 11:34:53 -07:00
|
|
|
this.imperativeRendererId = imperativeRendererId;
|
|
|
|
|
if (isPresent(imperativeRendererId)) {
|
|
|
|
|
this.rootBindingOffset = 0;
|
|
|
|
|
this.isTemplateElement = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.isTemplateElement = DOM.isTemplateElement(this.element);
|
|
|
|
|
this.rootBindingOffset = (isPresent(this.element) && DOM.hasClass(this.element, NG_BINDING_CLASS)) ? 1 : 0;
|
|
|
|
|
}
|
2015-03-23 14:10:55 -07:00
|
|
|
}
|
|
|
|
|
|
2015-05-06 11:22:28 -07:00
|
|
|
mergeChildComponentProtoViews(componentProtoViews:List<DomProtoView>) {
|
2015-04-07 17:24:09 -07:00
|
|
|
var componentProtoViewIndex = 0;
|
2015-03-23 14:10:55 -07:00
|
|
|
for (var i=0; i<this.elementBinders.length; i++) {
|
|
|
|
|
var eb = this.elementBinders[i];
|
2015-04-07 17:24:09 -07:00
|
|
|
if (isPresent(eb.componentId)) {
|
|
|
|
|
eb.nestedProtoView = componentProtoViews[componentProtoViewIndex];
|
|
|
|
|
componentProtoViewIndex++;
|
2015-03-23 14:10:55 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|