style(render): idiomatic TS
This commit is contained in:
parent
cebf69933c
commit
d64cc8d87d
|
@ -20,13 +20,7 @@ import {ASTWithSource} from 'angular2/change_detection';
|
|||
* its output will be stored in precompiled templates.
|
||||
*/
|
||||
export class EventBinding {
|
||||
fullName: string; // name/target:name, e.g "click", "window:resize"
|
||||
source: ASTWithSource;
|
||||
|
||||
constructor(fullName: string, source: ASTWithSource) {
|
||||
this.fullName = fullName;
|
||||
this.source = source;
|
||||
}
|
||||
constructor(public fullName: string, public source: ASTWithSource) {}
|
||||
}
|
||||
|
||||
export class ElementBinder {
|
||||
|
|
|
@ -8,20 +8,13 @@ import {CompileStep} from './compile_step';
|
|||
* Right now it only allows to add a parent element.
|
||||
*/
|
||||
export class CompileControl {
|
||||
_steps: List<CompileStep>;
|
||||
_currentStepIndex: number;
|
||||
_parent: CompileElement;
|
||||
_results;
|
||||
_additionalChildren;
|
||||
_currentStepIndex: number = 0;
|
||||
_parent: CompileElement = null;
|
||||
_results = null;
|
||||
_additionalChildren = null;
|
||||
_ignoreCurrentElement: boolean;
|
||||
|
||||
constructor(steps) {
|
||||
this._steps = steps;
|
||||
this._currentStepIndex = 0;
|
||||
this._parent = null;
|
||||
this._results = null;
|
||||
this._additionalChildren = null;
|
||||
}
|
||||
constructor(public _steps: List<CompileStep>) {}
|
||||
|
||||
// only public so that it can be used by compile_pipeline
|
||||
internalProcess(results, startStepIndex, parent: CompileElement, current: CompileElement) {
|
||||
|
|
|
@ -10,30 +10,19 @@ import {ProtoViewBuilder, ElementBinderBuilder} from '../view/proto_view_builder
|
|||
* by the CompileSteps starting out with the pure HTMLElement.
|
||||
*/
|
||||
export class CompileElement {
|
||||
element;
|
||||
_attrs: Map<string, string>;
|
||||
_classList: List<string>;
|
||||
isViewRoot: boolean;
|
||||
inheritedProtoView: ProtoViewBuilder;
|
||||
distanceToInheritedBinder: number;
|
||||
inheritedElementBinder: ElementBinderBuilder;
|
||||
compileChildren: boolean;
|
||||
_attrs: Map<string, string> = null;
|
||||
_classList: List<string> = null;
|
||||
isViewRoot: boolean = false;
|
||||
// inherited down to children if they don't have an own protoView
|
||||
inheritedProtoView: ProtoViewBuilder = null;
|
||||
distanceToInheritedBinder: number = 0;
|
||||
// inherited down to children if they don't have an own elementBinder
|
||||
inheritedElementBinder: ElementBinderBuilder = null;
|
||||
compileChildren: boolean = true;
|
||||
elementDescription: string; // e.g. '<div [class]="foo">' : used to provide context in case of
|
||||
// error
|
||||
|
||||
constructor(element, compilationUnit = '') {
|
||||
this.element = element;
|
||||
this._attrs = null;
|
||||
this._classList = null;
|
||||
this.isViewRoot = false;
|
||||
// inherited down to children if they don't have
|
||||
// an own protoView
|
||||
this.inheritedProtoView = null;
|
||||
// inherited down to children if they don't have
|
||||
// an own elementBinder
|
||||
this.inheritedElementBinder = null;
|
||||
this.distanceToInheritedBinder = 0;
|
||||
this.compileChildren = true;
|
||||
constructor(public element, compilationUnit: string = '') {
|
||||
// description is calculated here as compilation steps may change the element
|
||||
var tplDesc = assertionsEnabled() ? getElementDescription(element) : null;
|
||||
if (compilationUnit !== '') {
|
||||
|
|
|
@ -18,14 +18,7 @@ export class CompileStepFactory {
|
|||
}
|
||||
|
||||
export class DefaultStepFactory extends CompileStepFactory {
|
||||
_parser: Parser;
|
||||
_shadowDomStrategy: ShadowDomStrategy;
|
||||
|
||||
constructor(parser: Parser, shadowDomStrategy) {
|
||||
super();
|
||||
this._parser = parser;
|
||||
this._shadowDomStrategy = shadowDomStrategy;
|
||||
}
|
||||
constructor(public _parser: Parser, public _shadowDomStrategy: ShadowDomStrategy) { super(); }
|
||||
|
||||
createSteps(template: ViewDefinition, subTaskPromises: List<Promise<any>>) {
|
||||
return [
|
||||
|
|
|
@ -25,15 +25,10 @@ import {PropertySetterFactory} from '../view/property_setter_factory';
|
|||
* the CompilePipeline and the CompileSteps.
|
||||
*/
|
||||
export class DomCompiler extends RenderCompiler {
|
||||
_templateLoader: TemplateLoader;
|
||||
_stepFactory: CompileStepFactory;
|
||||
_propertySetterFactory: PropertySetterFactory;
|
||||
_propertySetterFactory: PropertySetterFactory = new PropertySetterFactory();
|
||||
|
||||
constructor(stepFactory: CompileStepFactory, templateLoader: TemplateLoader) {
|
||||
constructor(public _stepFactory: CompileStepFactory, public _templateLoader: TemplateLoader) {
|
||||
super();
|
||||
this._templateLoader = templateLoader;
|
||||
this._stepFactory = stepFactory;
|
||||
this._propertySetterFactory = new PropertySetterFactory();
|
||||
}
|
||||
|
||||
compile(template: ViewDefinition): Promise<ProtoViewDto> {
|
||||
|
|
|
@ -18,25 +18,18 @@ import {CompileControl} from './compile_control';
|
|||
|
||||
import {DirectiveMetadata} from '../../api';
|
||||
import {dashCaseToCamelCase, camelCaseToDashCase, EVENT_TARGET_SEPARATOR} from '../util';
|
||||
import {
|
||||
DirectiveBuilder
|
||||
} from '../view/proto_view_builder'
|
||||
import {DirectiveBuilder} from '../view/proto_view_builder';
|
||||
|
||||
/**
|
||||
* Parses the directives on a single element. Assumes ViewSplitter has already created
|
||||
* <template> elements for template directives.
|
||||
*/
|
||||
export class DirectiveParser implements CompileStep {
|
||||
_selectorMatcher: SelectorMatcher;
|
||||
_directives: List<DirectiveMetadata>;
|
||||
_parser: Parser;
|
||||
/**
|
||||
* Parses the directives on a single element. Assumes ViewSplitter has already created
|
||||
* <template> elements for template directives.
|
||||
*/
|
||||
export class DirectiveParser implements CompileStep {
|
||||
_selectorMatcher: SelectorMatcher = new SelectorMatcher();
|
||||
|
||||
constructor(parser: Parser, directives: List<DirectiveMetadata>) {
|
||||
this._parser = parser;
|
||||
this._selectorMatcher = new SelectorMatcher();
|
||||
this._directives = directives;
|
||||
for (var i = 0; i < directives.length; i++) {
|
||||
var directive = directives[i];
|
||||
constructor(public _parser: Parser, public _directives: List<DirectiveMetadata>) {
|
||||
for (var i = 0; i < _directives.length; i++) {
|
||||
var directive = _directives[i];
|
||||
var selector = CssSelector.parse(directive.selector);
|
||||
this._ensureComponentOnlyHasElementSelector(selector, directive);
|
||||
this._selectorMatcher.addSelectables(selector, i);
|
||||
|
|
|
@ -23,9 +23,7 @@ var BIND_NAME_REGEXP = RegExpWrapper.create(
|
|||
* Parses the property bindings on a single element.
|
||||
*/
|
||||
export class PropertyBindingParser implements CompileStep {
|
||||
_parser: Parser;
|
||||
|
||||
constructor(parser: Parser) { this._parser = parser; }
|
||||
constructor(public _parser: Parser) {}
|
||||
|
||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||
var attrs = current.attrs();
|
||||
|
|
|
@ -26,10 +26,11 @@ var _SELECTOR_REGEXP = RegExpWrapper.create(
|
|||
* of selecting subsets out of them.
|
||||
*/
|
||||
export class CssSelector {
|
||||
element: string;
|
||||
classNames: List<string>;
|
||||
attrs: List<string>;
|
||||
notSelectors: List<CssSelector>;
|
||||
element: string = null;
|
||||
classNames: List<string> = [];
|
||||
attrs: List<string> = [];
|
||||
notSelectors: List<CssSelector> = [];
|
||||
|
||||
static parse(selector: string): List<CssSelector> {
|
||||
var results = ListWrapper.create();
|
||||
var _addResult = (res, cssSel) => {
|
||||
|
@ -78,13 +79,6 @@ export class CssSelector {
|
|||
return results;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.element = null;
|
||||
this.classNames = ListWrapper.create();
|
||||
this.attrs = ListWrapper.create();
|
||||
this.notSelectors = ListWrapper.create();
|
||||
}
|
||||
|
||||
isElementSelector(): boolean {
|
||||
return isPresent(this.element) && ListWrapper.isEmpty(this.classNames) &&
|
||||
ListWrapper.isEmpty(this.attrs) && this.notSelectors.length === 0;
|
||||
|
@ -147,26 +141,13 @@ export class SelectorMatcher {
|
|||
return notMatcher;
|
||||
}
|
||||
|
||||
private _elementMap: Map<string, List<string>>;
|
||||
private _elementPartialMap: Map<string, SelectorMatcher>;
|
||||
private _classMap: Map<string, List<string>>;
|
||||
private _classPartialMap: Map<string, SelectorMatcher>;
|
||||
private _attrValueMap: Map<string, Map<string, List<string>>>;
|
||||
private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>>;
|
||||
private _listContexts: List<SelectorListContext>;
|
||||
|
||||
constructor() {
|
||||
this._elementMap = MapWrapper.create();
|
||||
this._elementPartialMap = MapWrapper.create();
|
||||
|
||||
this._classMap = MapWrapper.create();
|
||||
this._classPartialMap = MapWrapper.create();
|
||||
|
||||
this._attrValueMap = MapWrapper.create();
|
||||
this._attrValuePartialMap = MapWrapper.create();
|
||||
|
||||
this._listContexts = ListWrapper.create();
|
||||
}
|
||||
private _elementMap: Map<string, List<string>> = MapWrapper.create();
|
||||
private _elementPartialMap: Map<string, SelectorMatcher> = MapWrapper.create();
|
||||
private _classMap: Map<string, List<string>> = MapWrapper.create();
|
||||
private _classPartialMap: Map<string, SelectorMatcher> = MapWrapper.create();
|
||||
private _attrValueMap: Map<string, Map<string, List<string>>> = MapWrapper.create();
|
||||
private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>> = MapWrapper.create();
|
||||
private _listContexts: List<SelectorListContext> = [];
|
||||
|
||||
addSelectables(cssSelectors: List<CssSelector>, callbackCtxt?: any) {
|
||||
var listContext = null;
|
||||
|
@ -192,7 +173,6 @@ export class SelectorMatcher {
|
|||
var attrs = cssSelector.attrs;
|
||||
var selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
|
||||
|
||||
|
||||
if (isPresent(element)) {
|
||||
var isTerminal = attrs.length === 0 && classNames.length === 0;
|
||||
if (isTerminal) {
|
||||
|
@ -353,27 +333,18 @@ export class SelectorMatcher {
|
|||
|
||||
|
||||
class SelectorListContext {
|
||||
selectors: List<CssSelector>;
|
||||
alreadyMatched: boolean;
|
||||
alreadyMatched: boolean = false;
|
||||
|
||||
constructor(selectors: List<CssSelector>) {
|
||||
this.selectors = selectors;
|
||||
this.alreadyMatched = false;
|
||||
}
|
||||
constructor(public selectors: List<CssSelector>) {}
|
||||
}
|
||||
|
||||
// Store context to pass back selector and context when a selector is matched
|
||||
class SelectorContext {
|
||||
selector: CssSelector;
|
||||
notSelectors: List<CssSelector>;
|
||||
cbContext; // callback context
|
||||
listContext: SelectorListContext;
|
||||
|
||||
constructor(selector: CssSelector, cbContext: any, listContext: SelectorListContext) {
|
||||
this.selector = selector;
|
||||
constructor(public selector: CssSelector, public cbContext: any,
|
||||
public listContext: SelectorListContext) {
|
||||
this.notSelectors = selector.notSelectors;
|
||||
this.cbContext = cbContext;
|
||||
this.listContext = listContext;
|
||||
}
|
||||
|
||||
finalize(cssSelector: CssSelector, callback /*: (CssSelector, any) => void*/) {
|
||||
|
|
|
@ -15,13 +15,9 @@ import {UrlResolver} from 'angular2/src/services/url_resolver';
|
|||
*/
|
||||
@Injectable()
|
||||
export class TemplateLoader {
|
||||
_xhr: XHR;
|
||||
_htmlCache: StringMap<string, /*element*/ any>;
|
||||
_htmlCache: StringMap<string, /*element*/ any> = StringMapWrapper.create();
|
||||
|
||||
constructor(xhr: XHR, urlResolver: UrlResolver) {
|
||||
this._xhr = xhr;
|
||||
this._htmlCache = StringMapWrapper.create();
|
||||
}
|
||||
constructor(public _xhr: XHR, urlResolver: UrlResolver) {}
|
||||
|
||||
load(template: ViewDefinition): Promise</*element*/ any> {
|
||||
if (isPresent(template.template)) {
|
||||
|
|
|
@ -11,9 +11,7 @@ import {CompileControl} from './compile_control';
|
|||
* Parses interpolations in direct text child nodes of the current element.
|
||||
*/
|
||||
export class TextInterpolationParser implements CompileStep {
|
||||
_parser: Parser;
|
||||
|
||||
constructor(parser: Parser) { this._parser = parser; }
|
||||
constructor(public _parser: Parser) {}
|
||||
|
||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||
if (!current.compileChildren) {
|
||||
|
|
|
@ -26,9 +26,7 @@ import {dashCaseToCamelCase} from '../util';
|
|||
* which should not descend into the nested view.
|
||||
*/
|
||||
export class ViewSplitter implements CompileStep {
|
||||
_parser: Parser;
|
||||
|
||||
constructor(parser: Parser) { this._parser = parser; }
|
||||
constructor(public _parser: Parser) {}
|
||||
|
||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||
var attrs = current.attrs();
|
||||
|
|
|
@ -26,15 +26,11 @@ export const DOCUMENT_TOKEN = CONST_EXPR(new OpaqueToken('DocumentToken'));
|
|||
|
||||
@Injectable()
|
||||
export class DomRenderer extends Renderer {
|
||||
_eventManager: EventManager;
|
||||
_shadowDomStrategy: ShadowDomStrategy;
|
||||
_document;
|
||||
|
||||
constructor(eventManager: EventManager, shadowDomStrategy: ShadowDomStrategy,
|
||||
constructor(public _eventManager: EventManager, public _shadowDomStrategy: ShadowDomStrategy,
|
||||
@Inject(DOCUMENT_TOKEN) document) {
|
||||
super();
|
||||
this._eventManager = eventManager;
|
||||
this._shadowDomStrategy = shadowDomStrategy;
|
||||
this._document = document;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,9 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
|||
var BUBBLE_SYMBOL = '^';
|
||||
|
||||
export class EventManager {
|
||||
_plugins: List<EventManagerPlugin>;
|
||||
_zone: NgZone;
|
||||
|
||||
constructor(plugins: List<EventManagerPlugin>, zone: NgZone) {
|
||||
this._zone = zone;
|
||||
this._plugins = plugins;
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
plugins[i].manager = this;
|
||||
constructor(public _plugins: List<EventManagerPlugin>, public _zone: NgZone) {
|
||||
for (var i = 0; i < _plugins.length; i++) {
|
||||
_plugins[i].manager = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class ContentStrategy {
|
|||
* and thus does not affect redistribution.
|
||||
*/
|
||||
class RenderedContent extends ContentStrategy {
|
||||
beginScript;
|
||||
beginScript: any;
|
||||
endScript;
|
||||
|
||||
constructor(contentEl) {
|
||||
|
@ -47,12 +47,9 @@ class RenderedContent extends ContentStrategy {
|
|||
* and thus does not get rendered but only affect the distribution of its parent component.
|
||||
*/
|
||||
class IntermediateContent extends ContentStrategy {
|
||||
destinationLightDom: ldModule.LightDom;
|
||||
|
||||
constructor(destinationLightDom: ldModule.LightDom) {
|
||||
constructor(public destinationLightDom: ldModule.LightDom) {
|
||||
super();
|
||||
this.nodes = [];
|
||||
this.destinationLightDom = destinationLightDom;
|
||||
}
|
||||
|
||||
insert(nodes: List</*node*/ any>) {
|
||||
|
@ -63,15 +60,9 @@ class IntermediateContent extends ContentStrategy {
|
|||
|
||||
|
||||
export class Content {
|
||||
select: string;
|
||||
private _strategy: ContentStrategy;
|
||||
contentStartElement;
|
||||
private _strategy: ContentStrategy = null;
|
||||
|
||||
constructor(contentStartEl, selector: string) {
|
||||
this.select = selector;
|
||||
this.contentStartElement = contentStartEl;
|
||||
this._strategy = null;
|
||||
}
|
||||
constructor(public contentStartElement, public select: string) {}
|
||||
|
||||
init(destinationLightDom: ldModule.LightDom) {
|
||||
this._strategy = isPresent(destinationLightDom) ? new IntermediateContent(destinationLightDom) :
|
||||
|
|
|
@ -27,11 +27,8 @@ import {
|
|||
* - see `ShadowCss` for more information and limitations.
|
||||
*/
|
||||
export class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomStrategy {
|
||||
styleInliner: StyleInliner;
|
||||
|
||||
constructor(styleInliner: StyleInliner, styleUrlResolver: StyleUrlResolver, styleHost) {
|
||||
constructor(public styleInliner: StyleInliner, styleUrlResolver: StyleUrlResolver, styleHost) {
|
||||
super(styleUrlResolver, styleHost);
|
||||
this.styleInliner = styleInliner;
|
||||
}
|
||||
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleEl): Promise<any> {
|
||||
|
|
|
@ -19,14 +19,7 @@ import {insertSharedStyleText} from './util';
|
|||
* - you can **not** use shadow DOM specific selectors in the styles
|
||||
*/
|
||||
export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy {
|
||||
styleUrlResolver: StyleUrlResolver;
|
||||
styleHost;
|
||||
|
||||
constructor(styleUrlResolver: StyleUrlResolver, styleHost) {
|
||||
super();
|
||||
this.styleUrlResolver = styleUrlResolver;
|
||||
this.styleHost = styleHost;
|
||||
}
|
||||
constructor(public styleUrlResolver: StyleUrlResolver, public styleHost) { super(); }
|
||||
|
||||
hasNativeContentElement(): boolean { return false; }
|
||||
|
||||
|
|
|
@ -18,17 +18,14 @@ export class LightDom {
|
|||
// The light DOM of the element is enclosed inside the lightDomView
|
||||
lightDomView: viewModule.DomView;
|
||||
// The shadow DOM
|
||||
shadowDomView: viewModule.DomView;
|
||||
shadowDomView: viewModule.DomView = null;
|
||||
// The nodes of the light DOM
|
||||
nodes: List</*node*/ any>;
|
||||
private _roots: List<_Root>;
|
||||
private _roots: List<_Root> = null;
|
||||
|
||||
constructor(lightDomView: viewModule.DomView, element) {
|
||||
this.lightDomView = lightDomView;
|
||||
this.nodes = DOM.childNodesAsList(element);
|
||||
|
||||
this._roots = null;
|
||||
this.shadowDomView = null;
|
||||
}
|
||||
|
||||
attachShadowDomView(shadowDomView: viewModule.DomView) { this.shadowDomView = shadowDomView; }
|
||||
|
|
|
@ -14,12 +14,7 @@ import {ShadowDomStrategy} from './shadow_dom_strategy';
|
|||
*/
|
||||
@Injectable()
|
||||
export class NativeShadowDomStrategy extends ShadowDomStrategy {
|
||||
styleUrlResolver: StyleUrlResolver;
|
||||
|
||||
constructor(styleUrlResolver: StyleUrlResolver) {
|
||||
super();
|
||||
this.styleUrlResolver = styleUrlResolver;
|
||||
}
|
||||
constructor(public styleUrlResolver: StyleUrlResolver) { super(); }
|
||||
|
||||
prepareShadowRoot(el) { return DOM.createShadowRoot(el); }
|
||||
|
||||
|
|
|
@ -137,9 +137,9 @@ import {
|
|||
*/
|
||||
|
||||
export class ShadowCss {
|
||||
strictStyling: boolean;
|
||||
strictStyling: boolean = true;
|
||||
|
||||
constructor() { this.strictStyling = true; }
|
||||
constructor() {}
|
||||
|
||||
/*
|
||||
* Shim a style element with the given selector. Returns cssText that can
|
||||
|
|
|
@ -11,16 +11,8 @@ import {ViewDefinition} from '../../api';
|
|||
import {ShadowDomStrategy} from './shadow_dom_strategy';
|
||||
|
||||
export class ShadowDomCompileStep implements CompileStep {
|
||||
_shadowDomStrategy: ShadowDomStrategy;
|
||||
_template: ViewDefinition;
|
||||
_subTaskPromises: List<Promise<any>>;
|
||||
|
||||
constructor(shadowDomStrategy: ShadowDomStrategy, template: ViewDefinition,
|
||||
subTaskPromises: List<Promise<any>>) {
|
||||
this._shadowDomStrategy = shadowDomStrategy;
|
||||
this._template = template;
|
||||
this._subTaskPromises = subTaskPromises;
|
||||
}
|
||||
constructor(public _shadowDomStrategy: ShadowDomStrategy, public _template: ViewDefinition,
|
||||
public _subTaskPromises: List<Promise<any>>) {}
|
||||
|
||||
process(parent: CompileElement, current: CompileElement, control: CompileControl) {
|
||||
var tagName = DOM.tagName(current.element).toUpperCase();
|
||||
|
|
|
@ -25,15 +25,8 @@ import {
|
|||
*/
|
||||
@Injectable()
|
||||
export class StyleInliner {
|
||||
_xhr: XHR;
|
||||
_urlResolver: UrlResolver;
|
||||
_styleUrlResolver: StyleUrlResolver;
|
||||
|
||||
constructor(xhr: XHR, styleUrlResolver: StyleUrlResolver, urlResolver: UrlResolver) {
|
||||
this._xhr = xhr;
|
||||
this._urlResolver = urlResolver;
|
||||
this._styleUrlResolver = styleUrlResolver;
|
||||
}
|
||||
constructor(public _xhr: XHR, public _styleUrlResolver: StyleUrlResolver,
|
||||
public _urlResolver: UrlResolver) {}
|
||||
|
||||
/**
|
||||
* Inline the @imports rules in the given CSS text.
|
||||
|
|
|
@ -10,9 +10,7 @@ import {UrlResolver} from 'angular2/src/services/url_resolver';
|
|||
*/
|
||||
@Injectable()
|
||||
export class StyleUrlResolver {
|
||||
_resolver: UrlResolver;
|
||||
|
||||
constructor(resolver: UrlResolver) { this._resolver = resolver; }
|
||||
constructor(public _resolver: UrlResolver) {}
|
||||
|
||||
resolveUrls(cssText: string, baseUrl: string) {
|
||||
cssText = this._replaceUrls(cssText, _cssUrlRe, baseUrl);
|
||||
|
|
|
@ -49,25 +49,9 @@ export class ElementBinder {
|
|||
}
|
||||
|
||||
export class Event {
|
||||
name: string;
|
||||
target: string;
|
||||
fullName: string;
|
||||
|
||||
constructor(name: string, target: string, fullName: string) {
|
||||
this.name = name;
|
||||
this.target = target;
|
||||
this.fullName = fullName;
|
||||
}
|
||||
constructor(public name: string, public target: string, public fullName: string) {}
|
||||
}
|
||||
|
||||
export class HostAction {
|
||||
actionName: string;
|
||||
actionExpression: string;
|
||||
expression: AST;
|
||||
|
||||
constructor(actionName: string, actionExpression: string, expression: AST) {
|
||||
this.actionName = actionName;
|
||||
this.actionExpression = actionExpression;
|
||||
this.expression = expression;
|
||||
}
|
||||
constructor(public actionName: string, public actionExpression: string, public expression: AST) {}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,11 @@ export class PropertySetterFactory {
|
|||
|
||||
private _lazyPropertySettersCache: StringMap<string, Function> = StringMapWrapper.create();
|
||||
private _eagerPropertySettersCache: StringMap<string, Function> = StringMapWrapper.create();
|
||||
private _innerHTMLSetterCache: Function;
|
||||
private _innerHTMLSetterCache: Function = (el, value) => DOM.setInnerHTML(el, value);
|
||||
private _attributeSettersCache: StringMap<string, Function> = StringMapWrapper.create();
|
||||
private _classSettersCache: StringMap<string, Function> = StringMapWrapper.create();
|
||||
private _styleSettersCache: StringMap<string, Function> = StringMapWrapper.create();
|
||||
|
||||
constructor() { this._innerHTMLSetterCache = (el, value) => DOM.setInnerHTML(el, value); }
|
||||
|
||||
createSetter(protoElement: /*element*/ any, isNgComponent: boolean, property: string): Function {
|
||||
var setterFn, styleParts, styleSuffix;
|
||||
if (StringWrapper.startsWith(property, ATTRIBUTE_PREFIX)) {
|
||||
|
|
|
@ -13,11 +13,7 @@ export function resolveInternalDomProtoView(protoViewRef: RenderProtoViewRef) {
|
|||
}
|
||||
|
||||
export class DomProtoViewRef extends RenderProtoViewRef {
|
||||
_protoView: DomProtoView;
|
||||
constructor(protoView: DomProtoView) {
|
||||
super();
|
||||
this._protoView = protoView;
|
||||
}
|
||||
constructor(public _protoView: DomProtoView) { super(); }
|
||||
}
|
||||
|
||||
export class DomProtoView {
|
||||
|
|
|
@ -146,39 +146,21 @@ export class ProtoViewBuilder {
|
|||
}
|
||||
|
||||
export class ElementBinderBuilder {
|
||||
element;
|
||||
index: number;
|
||||
parent: ElementBinderBuilder;
|
||||
distanceToParent: number;
|
||||
directives: List<DirectiveBuilder>;
|
||||
nestedProtoView: ProtoViewBuilder;
|
||||
propertyBindings: Map<string, ASTWithSource>;
|
||||
variableBindings: Map<string, string>;
|
||||
eventBindings: List<api.EventBinding>;
|
||||
eventBuilder: EventBuilder;
|
||||
textBindingIndices: List<number>;
|
||||
textBindings: List<ASTWithSource>;
|
||||
contentTagSelector: string;
|
||||
readAttributes: Map<string, string>;
|
||||
componentId: string;
|
||||
parent: ElementBinderBuilder = null;
|
||||
distanceToParent: number = 0;
|
||||
directives: List<DirectiveBuilder> = [];
|
||||
nestedProtoView: ProtoViewBuilder = null;
|
||||
propertyBindings: Map<string, ASTWithSource> = MapWrapper.create();
|
||||
variableBindings: Map<string, string> = MapWrapper.create();
|
||||
eventBindings: List<api.EventBinding> = [];
|
||||
eventBuilder: EventBuilder = new EventBuilder();
|
||||
textBindingIndices: List<number> = [];
|
||||
textBindings: List<ASTWithSource> = [];
|
||||
contentTagSelector: string = null;
|
||||
readAttributes: Map<string, string> = MapWrapper.create();
|
||||
componentId: string = null;
|
||||
|
||||
constructor(index, element, description) {
|
||||
this.element = element;
|
||||
this.index = index;
|
||||
this.parent = null;
|
||||
this.distanceToParent = 0;
|
||||
this.directives = [];
|
||||
this.nestedProtoView = null;
|
||||
this.propertyBindings = MapWrapper.create();
|
||||
this.variableBindings = MapWrapper.create();
|
||||
this.eventBindings = ListWrapper.create();
|
||||
this.eventBuilder = new EventBuilder();
|
||||
this.textBindings = [];
|
||||
this.textBindingIndices = [];
|
||||
this.contentTagSelector = null;
|
||||
this.componentId = null;
|
||||
this.readAttributes = MapWrapper.create();
|
||||
}
|
||||
constructor(public index: number, public element, description: string) {}
|
||||
|
||||
setParent(parent: ElementBinderBuilder, distanceToParent): ElementBinderBuilder {
|
||||
this.parent = parent;
|
||||
|
@ -243,21 +225,13 @@ export class ElementBinderBuilder {
|
|||
}
|
||||
|
||||
export class DirectiveBuilder {
|
||||
directiveIndex: number;
|
||||
propertyBindings: Map<string, ASTWithSource>;
|
||||
hostPropertyBindings: Map<string, ASTWithSource>;
|
||||
hostActions: List<HostAction>;
|
||||
eventBindings: List<api.EventBinding>;
|
||||
eventBuilder: EventBuilder;
|
||||
propertyBindings: Map<string, ASTWithSource> = MapWrapper.create();
|
||||
hostPropertyBindings: Map<string, ASTWithSource> = MapWrapper.create();
|
||||
hostActions: List<HostAction> = [];
|
||||
eventBindings: List<api.EventBinding> = [];
|
||||
eventBuilder: EventBuilder = new EventBuilder();
|
||||
|
||||
constructor(directiveIndex) {
|
||||
this.directiveIndex = directiveIndex;
|
||||
this.propertyBindings = MapWrapper.create();
|
||||
this.hostPropertyBindings = MapWrapper.create();
|
||||
this.hostActions = ListWrapper.create();
|
||||
this.eventBindings = ListWrapper.create();
|
||||
this.eventBuilder = new EventBuilder();
|
||||
}
|
||||
constructor(public directiveIndex: number) {}
|
||||
|
||||
bindProperty(name, expression) { MapWrapper.set(this.propertyBindings, name, expression); }
|
||||
|
||||
|
@ -275,18 +249,12 @@ export class DirectiveBuilder {
|
|||
}
|
||||
|
||||
export class EventBuilder extends AstTransformer {
|
||||
locals: List<AST>;
|
||||
localEvents: List<Event>;
|
||||
globalEvents: List<Event>;
|
||||
_implicitReceiver: AST;
|
||||
locals: List<AST> = [];
|
||||
localEvents: List<Event> = [];
|
||||
globalEvents: List<Event> = [];
|
||||
_implicitReceiver: AST = new ImplicitReceiver();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.locals = [];
|
||||
this.localEvents = [];
|
||||
this.globalEvents = [];
|
||||
this._implicitReceiver = new ImplicitReceiver();
|
||||
}
|
||||
constructor() { super(); }
|
||||
|
||||
add(name: string, source: ASTWithSource, target: string): api.EventBinding {
|
||||
// TODO(tbosch): reenable this when we are parsing element properties
|
||||
|
|
|
@ -14,11 +14,7 @@ export function resolveInternalDomView(viewRef: RenderViewRef) {
|
|||
}
|
||||
|
||||
export class DomViewRef extends RenderViewRef {
|
||||
_view: DomView;
|
||||
constructor(view: DomView) {
|
||||
super();
|
||||
this._view = view;
|
||||
}
|
||||
constructor(public _view: DomView) { super(); }
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,20 +24,14 @@ const NG_BINDING_CLASS = 'ng-binding';
|
|||
* Const of making objects: http://jsperf.com/instantiate-size-of-object
|
||||
*/
|
||||
export class DomView {
|
||||
hostLightDom: LightDom;
|
||||
shadowRoot;
|
||||
hydrated: boolean;
|
||||
eventDispatcher: EventDispatcher;
|
||||
eventHandlerRemovers: List<Function>;
|
||||
hostLightDom: LightDom = null;
|
||||
shadowRoot = null;
|
||||
hydrated: boolean = false;
|
||||
eventDispatcher: EventDispatcher = null;
|
||||
eventHandlerRemovers: List<Function> = [];
|
||||
|
||||
constructor(public proto: DomProtoView, public rootNodes: List</*node*/ any>,
|
||||
public boundTextNodes: List</*node*/ any>, public boundElements: List<DomElement>) {
|
||||
this.hostLightDom = null;
|
||||
this.hydrated = false;
|
||||
this.eventHandlerRemovers = [];
|
||||
this.eventDispatcher = null;
|
||||
this.shadowRoot = null;
|
||||
}
|
||||
public boundTextNodes: List</*node*/ any>, public boundElements: List<DomElement>) {}
|
||||
|
||||
getDirectParentElement(boundElementIndex: number): DomElement {
|
||||
var binder = this.proto.elementBinders[boundElementIndex];
|
||||
|
|
|
@ -3,12 +3,8 @@ import {ListWrapper, MapWrapper, List} from 'angular2/src/facade/collection';
|
|||
import * as viewModule from './view';
|
||||
|
||||
export class DomViewContainer {
|
||||
views: List<viewModule.DomView>;
|
||||
|
||||
constructor() {
|
||||
// The order in this list matches the DOM order.
|
||||
this.views = [];
|
||||
}
|
||||
// The order in this list matches the DOM order.
|
||||
views: List<viewModule.DomView> = [];
|
||||
|
||||
contentTagContainers() { return this.views; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue