chore(ts2dart): replace List with Array

Closes #3514
This commit is contained in:
Misko Hevery 2015-08-28 11:29:19 -07:00 committed by Miško Hevery
parent 4415855683
commit e916836261
204 changed files with 815 additions and 947 deletions

View File

@ -1,7 +1,6 @@
{% extends '../type-definition.template.html' %} {% extends '../type-definition.template.html' %}
{% block staticDeclarations %} {% block staticDeclarations %}
interface List<T> extends Array<T> {}
interface Map<K,V> {} interface Map<K,V> {}
interface StringMap<K,V> extends Map<K,V> {} interface StringMap<K,V> extends Map<K,V> {}

View File

@ -60,5 +60,5 @@ export * from './src/core/directives/ng_switch';
* ``` * ```
* *
*/ */
export const CORE_DIRECTIVES: List<Type> = export const CORE_DIRECTIVES: Type[] =
CONST_EXPR([NgClass, NgFor, NgIf, NgNonBindable, NgSwitch, NgSwitchWhen, NgSwitchDefault]); CONST_EXPR([NgClass, NgFor, NgIf, NgNonBindable, NgSwitch, NgSwitchWhen, NgSwitchDefault]);

View File

@ -39,4 +39,4 @@ export {FormBuilder} from './src/forms/form_builder';
import {FormBuilder} from './src/forms/form_builder'; import {FormBuilder} from './src/forms/form_builder';
import {CONST_EXPR, Type} from './src/core/facade/lang'; import {CONST_EXPR, Type} from './src/core/facade/lang';
export const FORM_BINDINGS: List<Type> = CONST_EXPR([FormBuilder]); export const FORM_BINDINGS: Type[] = CONST_EXPR([FormBuilder]);

View File

@ -5,11 +5,9 @@
/// <reference path="typings/zone/zone.d.ts"/> /// <reference path="typings/zone/zone.d.ts"/>
declare var assert: any; declare var assert: any;
interface List<T> extends Array<T> {}
// FIXME: K must be string! // FIXME: K must be string!
// FIXME: should have an index signature, `[k: string]: V;` // FIXME: should have an index signature, `[k: string]: V;`
interface StringMap<K, V> {} interface StringMap<K extends string, V> {}
interface BrowserNodeGlobal { interface BrowserNodeGlobal {
Object: typeof Object; Object: typeof Object;

View File

@ -62,7 +62,7 @@ export {EventEmitter, Observable} from './src/core/facade/async';
* ``` * ```
* *
*/ */
export const HTTP_BINDINGS: List<any> = [ export const HTTP_BINDINGS: any[] = [
// TODO(pascal): use factory type annotations once supported in DI // TODO(pascal): use factory type annotations once supported in DI
// issue: https://github.com/angular/angular/issues/3183 // issue: https://github.com/angular/angular/issues/3183
bind(Http) bind(Http)
@ -74,7 +74,7 @@ export const HTTP_BINDINGS: List<any> = [
XHRBackend XHRBackend
]; ];
export const JSONP_BINDINGS: List<any> = [ export const JSONP_BINDINGS: any[] = [
// TODO(pascal): use factory type annotations once supported in DI // TODO(pascal): use factory type annotations once supported in DI
// issue: https://github.com/angular/angular/issues/3183 // issue: https://github.com/angular/angular/issues/3183
bind(Jsonp) bind(Jsonp)

View File

@ -35,11 +35,10 @@ import {Location} from './src/router/location';
import {APP_COMPONENT} from './src/core/application_tokens'; import {APP_COMPONENT} from './src/core/application_tokens';
import {Binding} from './di'; import {Binding} from './di';
import {CONST_EXPR} from './src/core/facade/lang'; import {CONST_EXPR} from './src/core/facade/lang';
import {List} from './src/core/facade/collection';
export const ROUTER_DIRECTIVES: List<any> = CONST_EXPR([RouterOutlet, RouterLink]); export const ROUTER_DIRECTIVES: any[] = CONST_EXPR([RouterOutlet, RouterLink]);
export const ROUTER_BINDINGS: List<any> = CONST_EXPR([ export const ROUTER_BINDINGS: any[] = CONST_EXPR([
RouteRegistry, RouteRegistry,
Pipeline, Pipeline,
CONST_EXPR(new Binding(LocationStrategy, {toClass: PathLocationStrategy})), CONST_EXPR(new Binding(LocationStrategy, {toClass: PathLocationStrategy})),

View File

@ -1,4 +1,3 @@
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import { import {
isPresent, isPresent,
StringWrapper, StringWrapper,
@ -56,8 +55,8 @@ function parseAttrs(element: Element, elementSourceInfo: string): HtmlAttrAst[]
// in DOM parsers! // in DOM parsers!
var attrMap = DOM.attributeMap(element); var attrMap = DOM.attributeMap(element);
var attrList: string[][] = []; var attrList: string[][] = [];
MapWrapper.forEach(attrMap, (value, name) => { attrList.push([name, value]); }); attrMap.forEach((value, name) => attrList.push([name, value]));
ListWrapper.sort(attrList, (entry1, entry2) => StringWrapper.compare(entry1[0], entry2[0])); attrList.sort((entry1, entry2) => StringWrapper.compare(entry1[0], entry2[0]));
return attrList.map(entry => parseAttr(element, elementSourceInfo, entry[0], entry[1])); return attrList.map(entry => parseAttr(element, elementSourceInfo, entry[0], entry[1]));
} }

View File

@ -33,7 +33,7 @@ import {StyleInliner} from 'angular2/src/core/render/dom/compiler/style_inliner'
import {ViewResolver} from './compiler/view_resolver'; import {ViewResolver} from './compiler/view_resolver';
import {DirectiveResolver} from './compiler/directive_resolver'; import {DirectiveResolver} from './compiler/directive_resolver';
import {PipeResolver} from './compiler/pipe_resolver'; import {PipeResolver} from './compiler/pipe_resolver';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/core/facade/async'; import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/core/facade/async';
import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
@ -84,7 +84,7 @@ var _rootInjector: Injector;
// Contains everything that is safe to share between applications. // Contains everything that is safe to share between applications.
var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry]; var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry];
function _injectorBindings(appComponentType): List<Type | Binding | List<any>> { function _injectorBindings(appComponentType): Array<Type | Binding | any[]> {
var bestChangeDetection = new DynamicChangeDetection(); var bestChangeDetection = new DynamicChangeDetection();
if (PreGeneratedChangeDetection.isSupported()) { if (PreGeneratedChangeDetection.isSupported()) {
bestChangeDetection = new PreGeneratedChangeDetection(); bestChangeDetection = new PreGeneratedChangeDetection();
@ -290,9 +290,9 @@ export function createNgZone(): NgZone {
* *
* Returns a `Promise` of {@link ApplicationRef}. * Returns a `Promise` of {@link ApplicationRef}.
*/ */
export function commonBootstrap( export function commonBootstrap(appComponentType: /*Type*/ any,
appComponentType: /*Type*/ any, componentInjectableBindings: Array<Type | Binding | any[]> = null):
componentInjectableBindings: List<Type | Binding | List<any>> = null): Promise<ApplicationRef> { Promise<ApplicationRef> {
BrowserDomAdapter.makeCurrent(); BrowserDomAdapter.makeCurrent();
wtfInit(); wtfInit();
var bootstrapProcess = PromiseWrapper.completer(); var bootstrapProcess = PromiseWrapper.completer();
@ -338,7 +338,7 @@ export function commonBootstrap(
return bootstrapProcess.promise; return bootstrapProcess.promise;
} }
function _createAppInjector(appComponentType: Type, bindings: List<Type | Binding | List<any>>, function _createAppInjector(appComponentType: Type, bindings: Array<Type | Binding | any[]>,
zone: NgZone): Injector { zone: NgZone): Injector {
if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings); if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings);
var mergedBindings: any[] = var mergedBindings: any[] =

View File

@ -1,5 +1,5 @@
import {isPresent, isBlank, BaseException, StringWrapper} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, BaseException, StringWrapper} from 'angular2/src/core/facade/lang';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {ChangeDetectionUtil} from './change_detection_util'; import {ChangeDetectionUtil} from './change_detection_util';
import {ChangeDetectorRef} from './change_detector_ref'; import {ChangeDetectorRef} from './change_detector_ref';
import {DirectiveIndex} from './directive_record'; import {DirectiveIndex} from './directive_record';
@ -25,8 +25,8 @@ class _Context {
} }
export class AbstractChangeDetector<T> implements ChangeDetector { export class AbstractChangeDetector<T> implements ChangeDetector {
lightDomChildren: List<any> = []; lightDomChildren: any[] = [];
shadowDomChildren: List<any> = []; shadowDomChildren: any[] = [];
parent: ChangeDetector; parent: ChangeDetector;
ref: ChangeDetectorRef; ref: ChangeDetectorRef;

View File

@ -12,7 +12,7 @@ import {
ChangeDetectorGenConfig ChangeDetectorGenConfig
} from './interfaces'; } from './interfaces';
import {Injector, Inject, Injectable, OpaqueToken, Optional, Binding} from 'angular2/di'; import {Injector, Inject, Injectable, OpaqueToken, Optional, Binding} from 'angular2/di';
import {List, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
import { import {
CONST, CONST,
CONST_EXPR, CONST_EXPR,

View File

@ -1,5 +1,5 @@
import {BaseException, Type, isBlank, isPresent} from 'angular2/src/core/facade/lang'; import {BaseException, Type, isBlank, isPresent} from 'angular2/src/core/facade/lang';
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {AbstractChangeDetector} from './abstract_change_detector'; import {AbstractChangeDetector} from './abstract_change_detector';
import {ChangeDetectionUtil} from './change_detection_util'; import {ChangeDetectionUtil} from './change_detection_util';
@ -36,8 +36,8 @@ export class ChangeDetectorJITGenerator {
_typeName: string; _typeName: string;
constructor(private id: string, private changeDetectionStrategy: ChangeDetectionStrategy, constructor(private id: string, private changeDetectionStrategy: ChangeDetectionStrategy,
private records: List<ProtoRecord>, private propertyBindingTargets: BindingTarget[], private records: ProtoRecord[], private propertyBindingTargets: BindingTarget[],
private eventBindings: EventBinding[], private directiveRecords: List<any>, private eventBindings: EventBinding[], private directiveRecords: any[],
private genConfig: ChangeDetectorGenConfig) { private genConfig: ChangeDetectorGenConfig) {
this._names = this._names =
new CodegenNameUtil(this.records, this.eventBindings, this.directiveRecords, UTIL); new CodegenNameUtil(this.records, this.eventBindings, this.directiveRecords, UTIL);

View File

@ -6,7 +6,7 @@ import {
Type, Type,
StringWrapper StringWrapper
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {ProtoRecord} from './proto_record'; import {ProtoRecord} from './proto_record';
import {ChangeDetectionStrategy, isDefaultChangeDetectionStrategy} from './constants'; import {ChangeDetectionStrategy, isDefaultChangeDetectionStrategy} from './constants';
import {implementsOnDestroy} from './pipe_lifecycle_reflector'; import {implementsOnDestroy} from './pipe_lifecycle_reflector';
@ -128,7 +128,7 @@ export class ChangeDetectionUtil {
static operation_logical_or(left, right): any { return left || right; } static operation_logical_or(left, right): any { return left || right; }
static cond(cond, trueVal, falseVal): any { return cond ? trueVal : falseVal; } static cond(cond, trueVal, falseVal): any { return cond ? trueVal : falseVal; }
static mapFn(keys: List<any>): any { static mapFn(keys: any[]): any {
function buildMap(values): StringMap<any, any> { function buildMap(values): StringMap<any, any> {
var res = StringMapWrapper.create(); var res = StringMapWrapper.create();
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; ++i) {

View File

@ -1,5 +1,5 @@
import {isPresent, isBlank, looseIdentical} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, looseIdentical} from 'angular2/src/core/facade/lang';
import {List, ListWrapper, Map} from 'angular2/src/core/facade/collection'; import {ListWrapper, Map} from 'angular2/src/core/facade/collection';
import {RecordType, ProtoRecord} from './proto_record'; import {RecordType, ProtoRecord} from './proto_record';
/** /**
@ -13,7 +13,7 @@ import {RecordType, ProtoRecord} from './proto_record';
* replaced with very cheap SELF records. * replaced with very cheap SELF records.
*/ */
export function coalesce(records: ProtoRecord[]): ProtoRecord[] { export function coalesce(records: ProtoRecord[]): ProtoRecord[] {
var res: List<ProtoRecord> = []; var res: ProtoRecord[] = [];
var indexMap: Map<number, number> = new Map<number, number>(); var indexMap: Map<number, number> = new Map<number, number>();
for (var i = 0; i < records.length; ++i) { for (var i = 0; i < records.length; ++i) {
@ -48,7 +48,7 @@ function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): P
r.lastInDirective, false, false, r.propertyBindingIndex); r.lastInDirective, false, false, r.propertyBindingIndex);
} }
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) { function _findMatching(r: ProtoRecord, rs: ProtoRecord[]) {
return ListWrapper.find( return ListWrapper.find(
rs, (rr) => rr.mode !== RecordType.DirectiveLifecycle && _sameDirIndex(rr, r) && rs, (rr) => rr.mode !== RecordType.DirectiveLifecycle && _sameDirIndex(rr, r) &&
rr.mode === r.mode && looseIdentical(rr.funcOrValue, r.funcOrValue) && rr.mode === r.mode && looseIdentical(rr.funcOrValue, r.funcOrValue) &&

View File

@ -1,4 +1,3 @@
import {List} from 'angular2/src/core/facade/collection';
/** /**
* Converts `funcOrValue` to a string which can be used in generated code. * Converts `funcOrValue` to a string which can be used in generated code.

View File

@ -1,5 +1,5 @@
import {RegExpWrapper, StringWrapper} from 'angular2/src/core/facade/lang'; import {RegExpWrapper, StringWrapper} from 'angular2/src/core/facade/lang';
import {List, ListWrapper, MapWrapper, Map} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, Map} from 'angular2/src/core/facade/collection';
import {DirectiveIndex} from './directive_record'; import {DirectiveIndex} from './directive_record';
@ -41,11 +41,11 @@ export class CodegenNameUtil {
* Record names sanitized for use as fields. * Record names sanitized for use as fields.
* See [sanitizeName] for details. * See [sanitizeName] for details.
*/ */
_sanitizedNames: List<string>; _sanitizedNames: string[];
_sanitizedEventNames: Map<EventBinding, List<string>>; _sanitizedEventNames: Map<EventBinding, string[]>;
constructor(private records: List<ProtoRecord>, private eventBindings: EventBinding[], constructor(private records: ProtoRecord[], private eventBindings: EventBinding[],
private directiveRecords: List<any>, private utilName: string) { private directiveRecords: any[], private utilName: string) {
this._sanitizedNames = ListWrapper.createFixedSize(this.records.length + 1); this._sanitizedNames = ListWrapper.createFixedSize(this.records.length + 1);
this._sanitizedNames[CONTEXT_INDEX] = _CONTEXT_ACCESSOR; this._sanitizedNames[CONTEXT_INDEX] = _CONTEXT_ACCESSOR;
for (var i = 0, iLen = this.records.length; i < iLen; ++i) { for (var i = 0, iLen = this.records.length; i < iLen; ++i) {
@ -135,7 +135,7 @@ export class CodegenNameUtil {
getFieldName(idx: number): string { return this._addFieldPrefix(this._sanitizedNames[idx]); } getFieldName(idx: number): string { return this._addFieldPrefix(this._sanitizedNames[idx]); }
getAllFieldNames(): List<string> { getAllFieldNames(): string[] {
var fieldList = []; var fieldList = [];
for (var k = 0, kLen = this.getFieldCount(); k < kLen; ++k) { for (var k = 0, kLen = this.getFieldCount(); k < kLen; ++k) {
if (k === 0 || this.records[k - 1].shouldBeChecked()) { if (k === 0 || this.records[k - 1].shouldBeChecked()) {

View File

@ -5,7 +5,7 @@ import {
FunctionWrapper, FunctionWrapper,
StringWrapper StringWrapper
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {AbstractChangeDetector} from './abstract_change_detector'; import {AbstractChangeDetector} from './abstract_change_detector';
import {EventBinding} from './event_binding'; import {EventBinding} from './event_binding';
@ -18,10 +18,10 @@ import {ChangeDetectionStrategy} from './constants';
import {ProtoRecord, RecordType} from './proto_record'; import {ProtoRecord, RecordType} from './proto_record';
export class DynamicChangeDetector extends AbstractChangeDetector<any> { export class DynamicChangeDetector extends AbstractChangeDetector<any> {
values: List<any>; values: any[];
changes: List<any>; changes: any[];
localPipes: List<any>; localPipes: any[];
prevContexts: List<any>; prevContexts: any[];
directives: any = null; directives: any = null;
constructor(id: string, dispatcher: any, numberOfPropertyProtoRecords: number, constructor(id: string, dispatcher: any, numberOfPropertyProtoRecords: number,

View File

@ -1,4 +1,3 @@
import {List} from 'angular2/src/core/facade/collection';
import {CONST} from 'angular2/src/core/facade/lang'; import {CONST} from 'angular2/src/core/facade/lang';
import {Locals} from './parser/locals'; import {Locals} from './parser/locals';
import {BindingTarget, BindingRecord} from './binding_record'; import {BindingTarget, BindingRecord} from './binding_record';
@ -83,7 +82,7 @@ export class ChangeDetectorGenConfig {
export class ChangeDetectorDefinition { export class ChangeDetectorDefinition {
constructor(public id: string, public strategy: ChangeDetectionStrategy, constructor(public id: string, public strategy: ChangeDetectionStrategy,
public variableNames: List<string>, public bindingRecords: BindingRecord[], public variableNames: string[], public bindingRecords: BindingRecord[],
public eventRecords: BindingRecord[], public directiveRecords: DirectiveRecord[], public eventRecords: BindingRecord[], public directiveRecords: DirectiveRecord[],
public genConfig: ChangeDetectorGenConfig) {} public genConfig: ChangeDetectorGenConfig) {}
} }

View File

@ -1,5 +1,5 @@
import {isBlank, isPresent, FunctionWrapper, BaseException} from "angular2/src/core/facade/lang"; import {isBlank, isPresent, FunctionWrapper, BaseException} from "angular2/src/core/facade/lang";
import {List, Map, ListWrapper, StringMapWrapper} from "angular2/src/core/facade/collection"; import {Map, ListWrapper, StringMapWrapper} from "angular2/src/core/facade/collection";
export class AST { export class AST {
visit(visitor: AstVisitor): any { return null; } visit(visitor: AstVisitor): any { return null; }
@ -20,7 +20,7 @@ export class ImplicitReceiver extends AST {
* Multiple expressions separated by a semicolon. * Multiple expressions separated by a semicolon.
*/ */
export class Chain extends AST { export class Chain extends AST {
constructor(public expressions: List<any>) { super(); } constructor(public expressions: any[]) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitChain(this); } visit(visitor: AstVisitor): any { return visitor.visitChain(this); }
} }
@ -63,7 +63,7 @@ export class KeyedWrite extends AST {
} }
export class BindingPipe extends AST { export class BindingPipe extends AST {
constructor(public exp: AST, public name: string, public args: List<any>) { super(); } constructor(public exp: AST, public name: string, public args: any[]) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitPipe(this); } visit(visitor: AstVisitor): any { return visitor.visitPipe(this); }
} }
@ -74,17 +74,17 @@ export class LiteralPrimitive extends AST {
} }
export class LiteralArray extends AST { export class LiteralArray extends AST {
constructor(public expressions: List<any>) { super(); } constructor(public expressions: any[]) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitLiteralArray(this); } visit(visitor: AstVisitor): any { return visitor.visitLiteralArray(this); }
} }
export class LiteralMap extends AST { export class LiteralMap extends AST {
constructor(public keys: List<any>, public values: List<any>) { super(); } constructor(public keys: any[], public values: any[]) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitLiteralMap(this); } visit(visitor: AstVisitor): any { return visitor.visitLiteralMap(this); }
} }
export class Interpolation extends AST { export class Interpolation extends AST {
constructor(public strings: List<any>, public expressions: List<any>) { super(); } constructor(public strings: any[], public expressions: any[]) { super(); }
visit(visitor: AstVisitor) { visitor.visitInterpolation(this); } visit(visitor: AstVisitor) { visitor.visitInterpolation(this); }
} }
@ -99,23 +99,21 @@ export class PrefixNot extends AST {
} }
export class MethodCall extends AST { export class MethodCall extends AST {
constructor(public receiver: AST, public name: string, public fn: Function, constructor(public receiver: AST, public name: string, public fn: Function, public args: any[]) {
public args: List<any>) {
super(); super();
} }
visit(visitor: AstVisitor): any { return visitor.visitMethodCall(this); } visit(visitor: AstVisitor): any { return visitor.visitMethodCall(this); }
} }
export class SafeMethodCall extends AST { export class SafeMethodCall extends AST {
constructor(public receiver: AST, public name: string, public fn: Function, constructor(public receiver: AST, public name: string, public fn: Function, public args: any[]) {
public args: List<any>) {
super(); super();
} }
visit(visitor: AstVisitor): any { return visitor.visitSafeMethodCall(this); } visit(visitor: AstVisitor): any { return visitor.visitSafeMethodCall(this); }
} }
export class FunctionCall extends AST { export class FunctionCall extends AST {
constructor(public target: AST, public args: List<any>) { super(); } constructor(public target: AST, public args: any[]) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitFunctionCall(this); } visit(visitor: AstVisitor): any { return visitor.visitFunctionCall(this); }
} }
@ -222,7 +220,7 @@ export class RecursiveAstVisitor implements AstVisitor {
ast.receiver.visit(this); ast.receiver.visit(this);
return this.visitAll(ast.args); return this.visitAll(ast.args);
} }
visitAll(asts: List<AST>): any { visitAll(asts: AST[]): any {
ListWrapper.forEach(asts, (ast) => { ast.visit(this); }); ListWrapper.forEach(asts, (ast) => { ast.visit(this); });
return null; return null;
} }
@ -294,7 +292,7 @@ export class AstTransformer implements AstVisitor {
return new KeyedWrite(ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this)); return new KeyedWrite(ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
} }
visitAll(asts: List<any>): List<any> { visitAll(asts: any[]): any[] {
var res = ListWrapper.createFixedSize(asts.length); var res = ListWrapper.createFixedSize(asts.length);
for (var i = 0; i < asts.length; ++i) { for (var i = 0; i < asts.length; ++i) {
res[i] = asts[i].visit(this); res[i] = asts[i].visit(this);

View File

@ -1,5 +1,5 @@
import {Injectable} from 'angular2/src/core/di/decorators'; import {Injectable} from 'angular2/src/core/di/decorators';
import {List, ListWrapper, SetWrapper} from "angular2/src/core/facade/collection"; import {ListWrapper, SetWrapper} from "angular2/src/core/facade/collection";
import { import {
NumberWrapper, NumberWrapper,
StringJoiner, StringJoiner,
@ -19,7 +19,7 @@ export enum TokenType {
@Injectable() @Injectable()
export class Lexer { export class Lexer {
tokenize(text: string): List<any> { tokenize(text: string): any[] {
var scanner = new _Scanner(text); var scanner = new _Scanner(text);
var tokens = []; var tokens = [];
var token = scanner.scanToken(); var token = scanner.scanToken();

View File

@ -1,6 +1,6 @@
import {Injectable} from 'angular2/src/core/di/decorators'; import {Injectable} from 'angular2/src/core/di/decorators';
import {isBlank, isPresent, BaseException, StringWrapper} from 'angular2/src/core/facade/lang'; import {isBlank, isPresent, BaseException, StringWrapper} from 'angular2/src/core/facade/lang';
import {ListWrapper, List} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import { import {
Lexer, Lexer,
EOF, EOF,
@ -85,7 +85,7 @@ export class Parser {
return new ASTWithSource(ast, input, location); return new ASTWithSource(ast, input, location);
} }
parseTemplateBindings(input: string, location: any): List<TemplateBinding> { parseTemplateBindings(input: string, location: any): TemplateBinding[] {
var tokens = this._lexer.tokenize(input); var tokens = this._lexer.tokenize(input);
return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings(); return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings();
} }
@ -141,7 +141,7 @@ export class Parser {
export class _ParseAST { export class _ParseAST {
index: number = 0; index: number = 0;
constructor(public input: string, public location: any, public tokens: List<any>, constructor(public input: string, public location: any, public tokens: any[],
public reflector: Reflector, public parseAction: boolean) {} public reflector: Reflector, public parseAction: boolean) {}
peek(offset: number): Token { peek(offset: number): Token {
@ -471,7 +471,7 @@ export class _ParseAST {
throw new BaseException("Fell through all cases in parsePrimary"); throw new BaseException("Fell through all cases in parsePrimary");
} }
parseExpressionList(terminator: number): List<any> { parseExpressionList(terminator: number): any[] {
var result = []; var result = [];
if (!this.next.isCharacter(terminator)) { if (!this.next.isCharacter(terminator)) {
do { do {
@ -677,7 +677,7 @@ class SimpleExpressionChecker implements AstVisitor {
visitKeyedWrite(ast: KeyedWrite) { this.simple = false; } visitKeyedWrite(ast: KeyedWrite) { this.simple = false; }
visitAll(asts: List<any>): List<any> { visitAll(asts: any[]): any[] {
var res = ListWrapper.createFixedSize(asts.length); var res = ListWrapper.createFixedSize(asts.length);
for (var i = 0; i < asts.length; ++i) { for (var i = 0; i < asts.length; ++i) {
res[i] = asts[i].visit(this); res[i] = asts[i].visit(this);

View File

@ -13,7 +13,7 @@ import {ABSTRACT, BaseException, CONST, Type} from 'angular2/src/core/facade/lan
* } * }
* ``` * ```
*/ */
export interface PipeTransform { transform(value: any, args: List<any>): any; } export interface PipeTransform { transform(value: any, args: any[]): any; }
/** /**
* An interface that stateful pipes should implement. * An interface that stateful pipes should implement.

View File

@ -1,5 +1,5 @@
import {BaseException, Type, isBlank, isPresent, isString} from 'angular2/src/core/facade/lang'; import {BaseException, Type, isBlank, isPresent, isString} from 'angular2/src/core/facade/lang';
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import { import {
PropertyRead, PropertyRead,
@ -76,7 +76,7 @@ export function createEventRecords(definition: ChangeDetectorDefinition): EventB
} }
export class ProtoRecordBuilder { export class ProtoRecordBuilder {
records: List<ProtoRecord>; records: ProtoRecord[];
constructor() { this.records = []; } constructor() { this.records = []; }
@ -117,16 +117,16 @@ export class ProtoRecordBuilder {
} }
class _ConvertAstIntoProtoRecords implements AstVisitor { class _ConvertAstIntoProtoRecords implements AstVisitor {
constructor(private _records: List<ProtoRecord>, private _bindingRecord: BindingRecord, constructor(private _records: ProtoRecord[], private _bindingRecord: BindingRecord,
private _variableNames: string[], private _bindingIndex: number) {} private _variableNames: string[], private _bindingIndex: number) {}
static append(records: List<ProtoRecord>, b: BindingRecord, variableNames: string[], static append(records: ProtoRecord[], b: BindingRecord, variableNames: string[],
bindingIndex: number) { bindingIndex: number) {
var c = new _ConvertAstIntoProtoRecords(records, b, variableNames, bindingIndex); var c = new _ConvertAstIntoProtoRecords(records, b, variableNames, bindingIndex);
b.ast.visit(c); b.ast.visit(c);
} }
static create(b: BindingRecord, variableNames: List<any>): ProtoRecord[] { static create(b: BindingRecord, variableNames: any[]): ProtoRecord[] {
var rec = []; var rec = [];
_ConvertAstIntoProtoRecords.append(rec, b, variableNames, null); _ConvertAstIntoProtoRecords.append(rec, b, variableNames, null);
rec[rec.length - 1].lastInBinding = true; rec[rec.length - 1].lastInBinding = true;
@ -256,7 +256,7 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
visitIf(ast: If) { throw new BaseException('Not supported'); } visitIf(ast: If) { throw new BaseException('Not supported'); }
_visitAll(asts: List<any>) { _visitAll(asts: any[]) {
var res = ListWrapper.createFixedSize(asts.length); var res = ListWrapper.createFixedSize(asts.length);
for (var i = 0; i < asts.length; ++i) { for (var i = 0; i < asts.length; ++i) {
res[i] = asts[i].visit(this); res[i] = asts[i].visit(this);
@ -307,7 +307,7 @@ function _arrayFn(length: number): Function {
} }
} }
function _mapPrimitiveName(keys: List<any>) { function _mapPrimitiveName(keys: any[]) {
var stringifiedKeys = var stringifiedKeys =
ListWrapper.join(ListWrapper.map(keys, (k) => isString(k) ? `"${k}"` : `${k}`), ", "); ListWrapper.join(ListWrapper.map(keys, (k) => isString(k) ? `"${k}"` : `${k}`), ", ");
return `mapFn([${stringifiedKeys}])`; return `mapFn([${stringifiedKeys}])`;
@ -391,7 +391,7 @@ function s(v): string {
return isPresent(v) ? `${v}` : ''; return isPresent(v) ? `${v}` : '';
} }
function _interpolationFn(strings: List<any>) { function _interpolationFn(strings: any[]) {
var length = strings.length; var length = strings.length;
var c0 = length > 0 ? strings[0] : null; var c0 = length > 0 ? strings[0] : null;
var c1 = length > 1 ? strings[1] : null; var c1 = length > 1 ? strings[1] : null;

View File

@ -1,4 +1,3 @@
import {List} from 'angular2/src/core/facade/collection';
import {BindingRecord} from './binding_record'; import {BindingRecord} from './binding_record';
import {DirectiveIndex} from './directive_record'; import {DirectiveIndex} from './directive_record';
@ -23,8 +22,8 @@ export enum RecordType {
} }
export class ProtoRecord { export class ProtoRecord {
constructor(public mode: RecordType, public name: string, public funcOrValue, constructor(public mode: RecordType, public name: string, public funcOrValue, public args: any[],
public args: List<any>, public fixedArgs: List<any>, public contextIndex: number, public fixedArgs: any[], public contextIndex: number,
public directiveIndex: DirectiveIndex, public selfIndex: number, public directiveIndex: DirectiveIndex, public selfIndex: number,
public bindingRecord: BindingRecord, public lastInBinding: boolean, public bindingRecord: BindingRecord, public lastInBinding: boolean,
public lastInDirective: boolean, public argumentToPureFunction: boolean, public lastInDirective: boolean, public argumentToPureFunction: boolean,

View File

@ -11,7 +11,7 @@ import {
isPromise isPromise
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, Map, MapWrapper} from 'angular2/src/core/facade/collection';
import {DirectiveResolver} from './directive_resolver'; import {DirectiveResolver} from './directive_resolver';
@ -212,7 +212,7 @@ export class Compiler {
return resultPromise; return resultPromise;
} }
private _removeDuplicatedDirectives(directives: List<DirectiveBinding>): List<DirectiveBinding> { private _removeDuplicatedDirectives(directives: DirectiveBinding[]): DirectiveBinding[] {
var directivesMap: Map<number, DirectiveBinding> = new Map(); var directivesMap: Map<number, DirectiveBinding> = new Map();
directives.forEach((dirBinding) => { directivesMap.set(dirBinding.key.id, dirBinding); }); directives.forEach((dirBinding) => { directivesMap.set(dirBinding.key.id, dirBinding); });
return MapWrapper.values(directivesMap); return MapWrapper.values(directivesMap);
@ -270,7 +270,7 @@ export class Compiler {
} }
private _collectMergeRenderProtoViews(appProtoView: private _collectMergeRenderProtoViews(appProtoView:
AppProtoView): List<RenderProtoViewRef | List<any>> { AppProtoView): Array<RenderProtoViewRef | any[]> {
var result = [appProtoView.render]; var result = [appProtoView.render];
for (var i = 0; i < appProtoView.elementBinders.length; i++) { for (var i = 0; i < appProtoView.elementBinders.length; i++) {
var binder = appProtoView.elementBinders[i]; var binder = appProtoView.elementBinders[i];
@ -330,14 +330,14 @@ export class Compiler {
return pipes; return pipes;
} }
private _flattenDirectives(view: ViewMetadata): List<Type> { private _flattenDirectives(view: ViewMetadata): Type[] {
if (isBlank(view.directives)) return []; if (isBlank(view.directives)) return [];
var directives = []; var directives = [];
this._flattenList(view.directives, directives); this._flattenList(view.directives, directives);
return directives; return directives;
} }
private _flattenList(tree: List<any>, out: List<Type | Binding | List<any>>): void { private _flattenList(tree: any[], out: Array<Type | Binding | any[]>): void {
for (var i = 0; i < tree.length; i++) { for (var i = 0; i < tree.length; i++) {
var item = resolveForwardRef(tree[i]); var item = resolveForwardRef(tree[i]);
if (isArray(item)) { if (isArray(item)) {

View File

@ -8,7 +8,7 @@ import {
StringWrapper StringWrapper
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import { import {
Injector, Injector,
ProtoInjector, ProtoInjector,
@ -163,7 +163,7 @@ export class TreeNode<T extends TreeNode<any>> {
export class DirectiveDependency extends Dependency { export class DirectiveDependency extends Dependency {
constructor(key: Key, optional: boolean, lowerBoundVisibility: Object, constructor(key: Key, optional: boolean, lowerBoundVisibility: Object,
upperBoundVisibility: Object, properties: List<any>, public attributeName: string, upperBoundVisibility: Object, properties: any[], public attributeName: string,
public queryDecorator: QueryMetadata) { public queryDecorator: QueryMetadata) {
super(key, optional, lowerBoundVisibility, upperBoundVisibility, properties); super(key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
this._verify(); this._verify();
@ -195,9 +195,9 @@ export class DirectiveDependency extends Dependency {
} }
export class DirectiveBinding extends ResolvedBinding { export class DirectiveBinding extends ResolvedBinding {
constructor(key: Key, factory: Function, dependencies: List<Dependency>, constructor(key: Key, factory: Function, dependencies: Dependency[],
public resolvedBindings: List<ResolvedBinding>, public resolvedBindings: ResolvedBinding[],
public resolvedViewBindings: List<ResolvedBinding>, public resolvedViewBindings: ResolvedBinding[],
public metadata: RenderDirectiveMetadata) { public metadata: RenderDirectiveMetadata) {
super(key, factory, dependencies); super(key, factory, dependencies);
} }
@ -210,7 +210,7 @@ export class DirectiveBinding extends ResolvedBinding {
get displayName(): string { return this.key.displayName; } get displayName(): string { return this.key.displayName; }
get eventEmitters(): List<string> { get eventEmitters(): string[] {
return isPresent(this.metadata) && isPresent(this.metadata.events) ? this.metadata.events : []; return isPresent(this.metadata) && isPresent(this.metadata.events) ? this.metadata.events : [];
} }
@ -294,7 +294,7 @@ export class HostActionAccessor {
subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object): Object { subscribe(view: viewModule.AppView, boundElementIndex: number, directive: Object): Object {
var eventEmitter = this.getter(directive); var eventEmitter = this.getter(directive);
return ObservableWrapper.subscribe<List<any>>( return ObservableWrapper.subscribe<any[]>(
eventEmitter, eventEmitter,
actionArgs => view.invokeElementMethod(boundElementIndex, this.methodName, actionArgs)); actionArgs => view.invokeElementMethod(boundElementIndex, this.methodName, actionArgs));
} }
@ -313,10 +313,10 @@ function _createEventEmitterAccessors(bwv: BindingWithVisibility): EventEmitterA
export class ProtoElementInjector { export class ProtoElementInjector {
view: viewModule.AppView; view: viewModule.AppView;
attributes: Map<string, string>; attributes: Map<string, string>;
eventEmitterAccessors: List<List<EventEmitterAccessor>>; eventEmitterAccessors: EventEmitterAccessor[][];
protoInjector: ProtoInjector; protoInjector: ProtoInjector;
static create(parent: ProtoElementInjector, index: number, bindings: List<ResolvedBinding>, static create(parent: ProtoElementInjector, index: number, bindings: ResolvedBinding[],
firstBindingIsComponent: boolean, distanceToParent: number, firstBindingIsComponent: boolean, distanceToParent: number,
directiveVariableBindings: Map<string, number>): ProtoElementInjector { directiveVariableBindings: Map<string, number>): ProtoElementInjector {
var bd = []; var bd = [];
@ -331,7 +331,7 @@ export class ProtoElementInjector {
directiveVariableBindings); directiveVariableBindings);
} }
private static _createDirectiveBindingWithVisibility(dirBindings: List<ResolvedBinding>, private static _createDirectiveBindingWithVisibility(dirBindings: ResolvedBinding[],
bd: BindingWithVisibility[], bd: BindingWithVisibility[],
firstBindingIsComponent: boolean) { firstBindingIsComponent: boolean) {
ListWrapper.forEach(dirBindings, dirBinding => { ListWrapper.forEach(dirBindings, dirBinding => {
@ -340,7 +340,7 @@ export class ProtoElementInjector {
}); });
} }
private static _createBindingsWithVisibility(dirBindings: List<ResolvedBinding>, private static _createBindingsWithVisibility(dirBindings: ResolvedBinding[],
bd: BindingWithVisibility[], bd: BindingWithVisibility[],
firstBindingIsComponent: boolean) { firstBindingIsComponent: boolean) {
ListWrapper.forEach(dirBindings, dirBinding => { ListWrapper.forEach(dirBindings, dirBinding => {
@ -358,7 +358,7 @@ export class ProtoElementInjector {
isComponent ? Visibility.PublicAndPrivate : Visibility.Public); isComponent ? Visibility.PublicAndPrivate : Visibility.Public);
} }
private static _createViewBindingsWithVisibility(bindings: List<ResolvedBinding>, private static _createViewBindingsWithVisibility(bindings: ResolvedBinding[],
bd: BindingWithVisibility[]) { bd: BindingWithVisibility[]) {
var db = <DirectiveBinding>bindings[0]; var db = <DirectiveBinding>bindings[0];
ListWrapper.forEach(db.resolvedViewBindings, ListWrapper.forEach(db.resolvedViewBindings,
@ -540,9 +540,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
hasDirective(type: Type): boolean { return isPresent(this._injector.getOptional(type)); } hasDirective(type: Type): boolean { return isPresent(this._injector.getOptional(type)); }
getEventEmitterAccessors(): List<List<EventEmitterAccessor>> { getEventEmitterAccessors(): EventEmitterAccessor[][] { return this._proto.eventEmitterAccessors; }
return this._proto.eventEmitterAccessors;
}
getDirectiveVariableBindings(): Map<string, number> { getDirectiveVariableBindings(): Map<string, number> {
return this._proto.directiveVariableBindings; return this._proto.directiveVariableBindings;
@ -628,7 +626,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
} }
} }
_buildQueriesForDeps(deps: List<DirectiveDependency>): void { _buildQueriesForDeps(deps: DirectiveDependency[]): void {
for (var i = 0; i < deps.length; i++) { for (var i = 0; i < deps.length; i++) {
var dep = deps[i]; var dep = deps[i];
if (isPresent(dep.queryDecorator)) { if (isPresent(dep.queryDecorator)) {
@ -948,34 +946,34 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = this.injectorStrategy.protoStrategy; var p = this.injectorStrategy.protoStrategy;
if (p.binding0 instanceof DirectiveBinding) { if (p.binding0 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding0.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding0.dependencies);
} }
if (p.binding1 instanceof DirectiveBinding) { if (p.binding1 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding1.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding1.dependencies);
} }
if (p.binding2 instanceof DirectiveBinding) { if (p.binding2 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding2.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding2.dependencies);
} }
if (p.binding3 instanceof DirectiveBinding) { if (p.binding3 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding3.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding3.dependencies);
} }
if (p.binding4 instanceof DirectiveBinding) { if (p.binding4 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding4.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding4.dependencies);
} }
if (p.binding5 instanceof DirectiveBinding) { if (p.binding5 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding5.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding5.dependencies);
} }
if (p.binding6 instanceof DirectiveBinding) { if (p.binding6 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding6.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding6.dependencies);
} }
if (p.binding7 instanceof DirectiveBinding) { if (p.binding7 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding7.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding7.dependencies);
} }
if (p.binding8 instanceof DirectiveBinding) { if (p.binding8 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding8.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding8.dependencies);
} }
if (p.binding9 instanceof DirectiveBinding) { if (p.binding9 instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.binding9.dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.binding9.dependencies);
} }
} }
@ -1081,7 +1079,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
for (var i = 0; i < p.bindings.length; i++) { for (var i = 0; i < p.bindings.length; i++) {
if (p.bindings[i] instanceof DirectiveBinding) { if (p.bindings[i] instanceof DirectiveBinding) {
this._ei._buildQueriesForDeps(<List<DirectiveDependency>>p.bindings[i].dependencies); this._ei._buildQueriesForDeps(<DirectiveDependency[]>p.bindings[i].dependencies);
} }
} }
} }
@ -1153,7 +1151,7 @@ export class QueryRef {
} }
} }
private _aggregateVariableBindings(inj: ElementInjector, aggregator: List<any>): void { private _aggregateVariableBindings(inj: ElementInjector, aggregator: any[]): void {
var vb = this.query.varBindings; var vb = this.query.varBindings;
for (var i = 0; i < vb.length; ++i) { for (var i = 0; i < vb.length; ++i) {
if (inj.hasVariableBinding(vb[i])) { if (inj.hasVariableBinding(vb[i])) {
@ -1162,7 +1160,7 @@ export class QueryRef {
} }
} }
private _aggregateDirective(inj: ElementInjector, aggregator: List<any>): void { private _aggregateDirective(inj: ElementInjector, aggregator: any[]): void {
inj.addDirectivesMatchingQuery(this.query, aggregator); inj.addDirectivesMatchingQuery(this.query, aggregator);
} }
} }

View File

@ -1,6 +1,6 @@
import {Injectable} from 'angular2/di'; import {Injectable} from 'angular2/di';
import {List, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
import { import {
StringWrapper, StringWrapper,
isPresent, isPresent,
@ -40,7 +40,7 @@ import {ProtoElementInjector, DirectiveBinding} from './element_injector';
export class BindingRecordsCreator { export class BindingRecordsCreator {
_directiveRecordsMap: Map<number, DirectiveRecord> = new Map(); _directiveRecordsMap: Map<number, DirectiveRecord> = new Map();
getEventBindingRecords(elementBinders: List<RenderElementBinder>, getEventBindingRecords(elementBinders: RenderElementBinder[],
allDirectiveMetadatas: RenderDirectiveMetadata[]): BindingRecord[] { allDirectiveMetadatas: RenderDirectiveMetadata[]): BindingRecord[] {
var res = []; var res = [];
for (var boundElementIndex = 0; boundElementIndex < elementBinders.length; for (var boundElementIndex = 0; boundElementIndex < elementBinders.length;
@ -75,10 +75,8 @@ export class BindingRecordsCreator {
} }
} }
getPropertyBindingRecords(textBindings: List<ASTWithSource>, getPropertyBindingRecords(textBindings: ASTWithSource[], elementBinders: RenderElementBinder[],
elementBinders: List<RenderElementBinder>, allDirectiveMetadatas: RenderDirectiveMetadata[]): BindingRecord[] {
allDirectiveMetadatas:
List<RenderDirectiveMetadata>): List<BindingRecord> {
var bindings = []; var bindings = [];
this._createTextNodeRecords(bindings, textBindings); this._createTextNodeRecords(bindings, textBindings);
@ -93,8 +91,8 @@ export class BindingRecordsCreator {
return bindings; return bindings;
} }
getDirectiveRecords(elementBinders: List<RenderElementBinder>, getDirectiveRecords(elementBinders: RenderElementBinder[],
allDirectiveMetadatas: List<RenderDirectiveMetadata>): List<DirectiveRecord> { allDirectiveMetadatas: RenderDirectiveMetadata[]): DirectiveRecord[] {
var directiveRecords = []; var directiveRecords = [];
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) { for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
@ -108,13 +106,13 @@ export class BindingRecordsCreator {
return directiveRecords; return directiveRecords;
} }
_createTextNodeRecords(bindings: List<BindingRecord>, textBindings: List<ASTWithSource>) { _createTextNodeRecords(bindings: BindingRecord[], textBindings: ASTWithSource[]) {
for (var i = 0; i < textBindings.length; i++) { for (var i = 0; i < textBindings.length; i++) {
bindings.push(BindingRecord.createForTextNode(textBindings[i], i)); bindings.push(BindingRecord.createForTextNode(textBindings[i], i));
} }
} }
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number, _createElementPropertyRecords(bindings: BindingRecord[], boundElementIndex: number,
renderElementBinder: RenderElementBinder) { renderElementBinder: RenderElementBinder) {
ListWrapper.forEach(renderElementBinder.propertyBindings, (binding) => { ListWrapper.forEach(renderElementBinder.propertyBindings, (binding) => {
if (binding.type === PropertyBindingType.PROPERTY) { if (binding.type === PropertyBindingType.PROPERTY) {
@ -133,9 +131,9 @@ export class BindingRecordsCreator {
}); });
} }
_createDirectiveRecords(bindings: List<BindingRecord>, boundElementIndex: number, _createDirectiveRecords(bindings: BindingRecord[], boundElementIndex: number,
directiveBinders: List<DirectiveBinder>, directiveBinders: DirectiveBinder[],
allDirectiveMetadatas: List<RenderDirectiveMetadata>) { allDirectiveMetadatas: RenderDirectiveMetadata[]) {
for (var i = 0; i < directiveBinders.length; i++) { for (var i = 0; i < directiveBinders.length; i++) {
var directiveBinder = directiveBinders[i]; var directiveBinder = directiveBinders[i];
var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex]; var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex];
@ -214,7 +212,7 @@ export class ProtoViewFactory {
constructor(public _changeDetection: ChangeDetection) {} constructor(public _changeDetection: ChangeDetection) {}
createAppProtoViews(hostComponentBinding: DirectiveBinding, rootRenderProtoView: ProtoViewDto, createAppProtoViews(hostComponentBinding: DirectiveBinding, rootRenderProtoView: ProtoViewDto,
allDirectives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] { allDirectives: DirectiveBinding[], pipes: PipeBinding[]): AppProtoView[] {
var allRenderDirectiveMetadata = var allRenderDirectiveMetadata =
ListWrapper.map(allDirectives, directiveBinding => directiveBinding.metadata); ListWrapper.map(allDirectives, directiveBinding => directiveBinding.metadata);
var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView); var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView);
@ -264,8 +262,8 @@ export class ProtoViewFactory {
*/ */
export function getChangeDetectorDefinitions( export function getChangeDetectorDefinitions(
hostComponentMetadata: RenderDirectiveMetadata, rootRenderProtoView: ProtoViewDto, hostComponentMetadata: RenderDirectiveMetadata, rootRenderProtoView: ProtoViewDto,
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>, genConfig: ChangeDetectorGenConfig): allRenderDirectiveMetadata: RenderDirectiveMetadata[], genConfig: ChangeDetectorGenConfig):
List<ChangeDetectorDefinition> { ChangeDetectorDefinition[] {
var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView); var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView);
var nestedPvVariableNames = _collectNestedProtoViewsVariableNames(nestedPvsWithIndex); var nestedPvVariableNames = _collectNestedProtoViewsVariableNames(nestedPvsWithIndex);
return _getChangeDetectorDefinitions(hostComponentMetadata, nestedPvsWithIndex, return _getChangeDetectorDefinitions(hostComponentMetadata, nestedPvsWithIndex,
@ -275,7 +273,7 @@ export function getChangeDetectorDefinitions(
function _collectNestedProtoViews( function _collectNestedProtoViews(
renderProtoView: ProtoViewDto, parentIndex: number = null, boundElementIndex = null, renderProtoView: ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
result: List<RenderProtoViewWithIndex> = null): List<RenderProtoViewWithIndex> { result: RenderProtoViewWithIndex[] = null): RenderProtoViewWithIndex[] {
if (isBlank(result)) { if (isBlank(result)) {
result = []; result = [];
} }
@ -295,10 +293,9 @@ function _collectNestedProtoViews(
} }
function _getChangeDetectorDefinitions( function _getChangeDetectorDefinitions(
hostComponentMetadata: RenderDirectiveMetadata, hostComponentMetadata: RenderDirectiveMetadata, nestedPvsWithIndex: RenderProtoViewWithIndex[],
nestedPvsWithIndex: List<RenderProtoViewWithIndex>, nestedPvVariableNames: List<List<string>>, nestedPvVariableNames: string[][], allRenderDirectiveMetadata: RenderDirectiveMetadata[],
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>, genConfig: ChangeDetectorGenConfig): genConfig: ChangeDetectorGenConfig): ChangeDetectorDefinition[] {
List<ChangeDetectorDefinition> {
return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => { return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => {
var elementBinders = pvWithIndex.renderProtoView.elementBinders; var elementBinders = pvWithIndex.renderProtoView.elementBinders;
var bindingRecordsCreator = new BindingRecordsCreator(); var bindingRecordsCreator = new BindingRecordsCreator();
@ -320,8 +317,7 @@ function _getChangeDetectorDefinitions(
} }
function _getChangeDetectorDefinitionIds(hostComponentMetadata: RenderDirectiveMetadata, function _getChangeDetectorDefinitionIds(hostComponentMetadata: RenderDirectiveMetadata,
nestedPvsWithIndex: List<RenderProtoViewWithIndex>): nestedPvsWithIndex: RenderProtoViewWithIndex[]): string[] {
string[] {
return nestedPvsWithIndex.map(pvWithIndex => _protoViewId(hostComponentMetadata, pvWithIndex)); return nestedPvsWithIndex.map(pvWithIndex => _protoViewId(hostComponentMetadata, pvWithIndex));
} }
@ -340,8 +336,8 @@ function _protoViewId(hostComponentMetadata: RenderDirectiveMetadata,
function _createAppProtoView( function _createAppProtoView(
renderProtoView: ProtoViewDto, protoChangeDetector: ProtoChangeDetector, renderProtoView: ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
variableBindings: Map<string, string>, allDirectives: List<DirectiveBinding>, variableBindings: Map<string, string>, allDirectives: DirectiveBinding[], pipes: PipeBinding[]):
pipes: PipeBinding[]): AppProtoView { AppProtoView {
var elementBinders = renderProtoView.elementBinders; var elementBinders = renderProtoView.elementBinders;
// Embedded ProtoViews that contain `<ng-content>` will be merged into their parents and use // Embedded ProtoViews that contain `<ng-content>` will be merged into their parents and use
// a RenderFragmentRef. I.e. renderProtoView.transitiveNgContentCount > 0. // a RenderFragmentRef. I.e. renderProtoView.transitiveNgContentCount > 0.
@ -354,8 +350,8 @@ function _createAppProtoView(
return protoView; return protoView;
} }
function _collectNestedProtoViewsVariableBindings( function _collectNestedProtoViewsVariableBindings(nestedPvsWithIndex: RenderProtoViewWithIndex[]):
nestedPvsWithIndex: List<RenderProtoViewWithIndex>): List<Map<string, string>> { Array<Map<string, string>> {
return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => { return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => {
return _createVariableBindings(pvWithIndex.renderProtoView); return _createVariableBindings(pvWithIndex.renderProtoView);
}); });
@ -368,8 +364,8 @@ function _createVariableBindings(renderProtoView): Map<string, string> {
return variableBindings; return variableBindings;
} }
function _collectNestedProtoViewsVariableNames(nestedPvsWithIndex: List<RenderProtoViewWithIndex>): function _collectNestedProtoViewsVariableNames(nestedPvsWithIndex: RenderProtoViewWithIndex[]):
List<List<string>> { string[][] {
var nestedPvVariableNames = ListWrapper.createFixedSize(nestedPvsWithIndex.length); var nestedPvVariableNames = ListWrapper.createFixedSize(nestedPvsWithIndex.length);
ListWrapper.forEach(nestedPvsWithIndex, (pvWithIndex) => { ListWrapper.forEach(nestedPvsWithIndex, (pvWithIndex) => {
var parentVariableNames = var parentVariableNames =
@ -380,9 +376,8 @@ function _collectNestedProtoViewsVariableNames(nestedPvsWithIndex: List<RenderPr
return nestedPvVariableNames; return nestedPvVariableNames;
} }
function _createVariableNames(parentVariableNames: List<string>, renderProtoView): List<string> { function _createVariableNames(parentVariableNames: string[], renderProtoView): string[] {
var res = var res = isBlank(parentVariableNames) ? <string[]>[] : ListWrapper.clone(parentVariableNames);
isBlank(parentVariableNames) ? <List<string>>[] : ListWrapper.clone(parentVariableNames);
MapWrapper.forEach(renderProtoView.variableBindings, MapWrapper.forEach(renderProtoView.variableBindings,
(mappedName, varName) => { res.push(mappedName); }); (mappedName, varName) => { res.push(mappedName); });
ListWrapper.forEach(renderProtoView.elementBinders, binder => { ListWrapper.forEach(renderProtoView.elementBinders, binder => {
@ -392,7 +387,7 @@ function _createVariableNames(parentVariableNames: List<string>, renderProtoView
return res; return res;
} }
export function createVariableLocations(elementBinders: List<RenderElementBinder>): export function createVariableLocations(elementBinders: RenderElementBinder[]):
Map<string, number> { Map<string, number> {
var variableLocations = new Map(); var variableLocations = new Map();
for (var i = 0; i < elementBinders.length; i++) { for (var i = 0; i < elementBinders.length; i++) {
@ -486,7 +481,7 @@ function _createElementBinder(protoView: AppProtoView, boundElementIndex, render
} }
export function createDirectiveVariableBindings(renderElementBinder: RenderElementBinder, export function createDirectiveVariableBindings(renderElementBinder: RenderElementBinder,
directiveBindings: List<DirectiveBinding>): directiveBindings: DirectiveBinding[]):
Map<string, number> { Map<string, number> {
var directiveVariableBindings = new Map(); var directiveVariableBindings = new Map();
MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => { MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => {

View File

@ -1,4 +1,4 @@
import {List, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
/** /**
* An iterable and observable live list of components in the DOM. * An iterable and observable live list of components in the DOM.
@ -72,11 +72,11 @@ import {List, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection
* ``` * ```
*/ */
export class QueryList<T> { export class QueryList<T> {
protected _results: List < T >= []; protected _results: Array < T >= [];
protected _callbacks: List < () => void >= []; protected _callbacks: Array < () => void >= [];
protected _dirty: boolean = false; protected _dirty: boolean = false;
reset(newList: List<T>): void { reset(newList: T[]): void {
this._results = newList; this._results = newList;
this._dirty = true; this._dirty = true;
} }

View File

@ -3,7 +3,6 @@ import {
MapWrapper, MapWrapper,
Map, Map,
StringMapWrapper, StringMapWrapper,
List,
StringMap StringMap
} from 'angular2/src/core/facade/collection'; } from 'angular2/src/core/facade/collection';
import { import {
@ -74,7 +73,7 @@ function inverseIndexMapping(input: number[], resultLength: number): number[] {
export class AppViewContainer { export class AppViewContainer {
// The order in this list matches the DOM order. // The order in this list matches the DOM order.
views: List<AppView> = []; views: AppView[] = [];
} }
/** /**
@ -85,26 +84,26 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
// AppViews that have been merged in depth first order. // AppViews that have been merged in depth first order.
// This list is shared between all merged views. Use this.elementOffset to get the local // This list is shared between all merged views. Use this.elementOffset to get the local
// entries. // entries.
views: List<AppView> = null; views: AppView[] = null;
// root elementInjectors of this AppView // root elementInjectors of this AppView
// This list is local to this AppView and not shared with other Views. // This list is local to this AppView and not shared with other Views.
rootElementInjectors: List<ElementInjector>; rootElementInjectors: ElementInjector[];
// ElementInjectors of all AppViews in views grouped by view. // ElementInjectors of all AppViews in views grouped by view.
// This list is shared between all merged views. Use this.elementOffset to get the local // This list is shared between all merged views. Use this.elementOffset to get the local
// entries. // entries.
elementInjectors: List<ElementInjector> = null; elementInjectors: ElementInjector[] = null;
// ViewContainers of all AppViews in views grouped by view. // ViewContainers of all AppViews in views grouped by view.
// This list is shared between all merged views. Use this.elementOffset to get the local // This list is shared between all merged views. Use this.elementOffset to get the local
// entries. // entries.
viewContainers: List<AppViewContainer> = null; viewContainers: AppViewContainer[] = null;
// PreBuiltObjects of all AppViews in views grouped by view. // PreBuiltObjects of all AppViews in views grouped by view.
// This list is shared between all merged views. Use this.elementOffset to get the local // This list is shared between all merged views. Use this.elementOffset to get the local
// entries. // entries.
preBuiltObjects: List<PreBuiltObjects> = null; preBuiltObjects: PreBuiltObjects[] = null;
// ElementRef of all AppViews in views grouped by view. // ElementRef of all AppViews in views grouped by view.
// This list is shared between all merged views. Use this.elementOffset to get the local // This list is shared between all merged views. Use this.elementOffset to get the local
// entries. // entries.
elementRefs: List<ElementRef>; elementRefs: ElementRef[];
ref: ViewRef; ref: ViewRef;
changeDetector: ChangeDetector = null; changeDetector: ChangeDetector = null;
@ -134,10 +133,9 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
this.locals = new Locals(null, MapWrapper.clone(protoLocals)); // TODO optimize this this.locals = new Locals(null, MapWrapper.clone(protoLocals)); // TODO optimize this
} }
init(changeDetector: ChangeDetector, elementInjectors: List<ElementInjector>, init(changeDetector: ChangeDetector, elementInjectors: ElementInjector[],
rootElementInjectors: List<ElementInjector>, preBuiltObjects: List<PreBuiltObjects>, rootElementInjectors: ElementInjector[], preBuiltObjects: PreBuiltObjects[],
views: List<AppView>, elementRefs: List<ElementRef>, views: AppView[], elementRefs: ElementRef[], viewContainers: AppViewContainer[]) {
viewContainers: List<AppViewContainer>) {
this.changeDetector = changeDetector; this.changeDetector = changeDetector;
this.elementInjectors = elementInjectors; this.elementInjectors = elementInjectors;
this.rootElementInjectors = rootElementInjectors; this.rootElementInjectors = rootElementInjectors;
@ -260,7 +258,7 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
return isPresent(childView) ? childView.changeDetector : null; return isPresent(childView) ? childView.changeDetector : null;
} }
invokeElementMethod(elementIndex: number, methodName: string, args: List<any>) { invokeElementMethod(elementIndex: number, methodName: string, args: any[]) {
this.renderer.invokeElementMethod(this.elementRefs[elementIndex], methodName, args); this.renderer.invokeElementMethod(this.elementRefs[elementIndex], methodName, args);
} }
@ -325,7 +323,7 @@ class EventEvaluationError extends BaseException {
* *
*/ */
export class AppProtoView { export class AppProtoView {
elementBinders: List<ElementBinder> = []; elementBinders: ElementBinder[] = [];
protoLocals: Map<string, any> = new Map(); protoLocals: Map<string, any> = new Map();
mergeMapping: AppProtoViewMergeMapping; mergeMapping: AppProtoViewMergeMapping;
ref: ProtoViewRef; ref: ProtoViewRef;

View File

@ -1,4 +1,4 @@
import {ListWrapper, List} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {ResolvedBinding} from 'angular2/di'; import {ResolvedBinding} from 'angular2/di';
import {isPresent, isBlank} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
@ -22,7 +22,7 @@ export class ViewContainerRef {
*/ */
constructor(public viewManager: avmModule.AppViewManager, public element: ElementRef) {} constructor(public viewManager: avmModule.AppViewManager, public element: ElementRef) {}
private _getViews(): List<viewModule.AppView> { private _getViews(): Array<viewModule.AppView> {
var vc = internalView(this.element.parentView).viewContainers[this.element.boundElementIndex]; var vc = internalView(this.element.parentView).viewContainers[this.element.boundElementIndex];
return isPresent(vc) ? vc.views : []; return isPresent(vc) ? vc.views : [];
} }

View File

@ -1,11 +1,5 @@
import {Injector, Binding, Injectable, ResolvedBinding} from 'angular2/di'; import {Injector, Binding, Injectable, ResolvedBinding} from 'angular2/di';
import { import {ListWrapper, MapWrapper, Map, StringMapWrapper} from 'angular2/src/core/facade/collection';
ListWrapper,
MapWrapper,
Map,
StringMapWrapper,
List
} from 'angular2/src/core/facade/collection';
import * as eli from './element_injector'; import * as eli from './element_injector';
import {isPresent, isBlank, BaseException} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, BaseException} from 'angular2/src/core/facade/lang';
import * as viewModule from './view'; import * as viewModule from './view';

View File

@ -1,6 +1,6 @@
import {Inject, Injectable, OpaqueToken} from 'angular2/di'; import {Inject, Injectable, OpaqueToken} from 'angular2/di';
import {ListWrapper, MapWrapper, Map, List} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, Map} from 'angular2/src/core/facade/collection';
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';
import * as viewModule from './view'; import * as viewModule from './view';
@ -10,7 +10,7 @@ export const APP_VIEW_POOL_CAPACITY = CONST_EXPR(new OpaqueToken('AppViewPool.vi
@Injectable() @Injectable()
export class AppViewPool { export class AppViewPool {
_poolCapacityPerProtoView: number; _poolCapacityPerProtoView: number;
_pooledViewsPerProtoView: Map<viewModule.AppProtoView, List<viewModule.AppView>> = new Map(); _pooledViewsPerProtoView: Map<viewModule.AppProtoView, Array<viewModule.AppView>> = new Map();
constructor(@Inject(APP_VIEW_POOL_CAPACITY) poolCapacityPerProtoView) { constructor(@Inject(APP_VIEW_POOL_CAPACITY) poolCapacityPerProtoView) {
this._poolCapacityPerProtoView = poolCapacityPerProtoView; this._poolCapacityPerProtoView = poolCapacityPerProtoView;

View File

@ -2,7 +2,7 @@ import {Injectable} from 'angular2/di';
import {ViewMetadata} from '../metadata/view'; import {ViewMetadata} from '../metadata/view';
import {Type, stringify, isBlank, BaseException} from 'angular2/src/core/facade/lang'; import {Type, stringify, isBlank, BaseException} from 'angular2/src/core/facade/lang';
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/core/facade/collection'; import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {reflector} from 'angular2/src/core/reflection/reflection'; import {reflector} from 'angular2/src/core/reflection/reflection';

View File

@ -1,5 +1,5 @@
import {Type, isPresent, BaseException, isBlank} from 'angular2/src/core/facade/lang'; import {Type, isPresent, BaseException, isBlank} from 'angular2/src/core/facade/lang';
import {List, ListWrapper, MapWrapper, Predicate} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper, Predicate} from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
@ -42,9 +42,9 @@ export class DebugElement {
/** /**
* Get child DebugElements from within the Light DOM. * Get child DebugElements from within the Light DOM.
* *
* @return {List<DebugElement>} * @return {DebugElement[]}
*/ */
get children(): List<DebugElement> { get children(): DebugElement[] {
return this._getChildElements(this._parentView, this._boundElementIndex); return this._getChildElements(this._parentView, this._boundElementIndex);
} }
@ -52,9 +52,9 @@ export class DebugElement {
* Get the root DebugElement children of a component. Returns an empty * Get the root DebugElement children of a component. Returns an empty
* list if the current DebugElement is not a component root. * list if the current DebugElement is not a component root.
* *
* @return {List<DebugElement>} * @return {DebugElement[]}
*/ */
get componentViewChildren(): List<DebugElement> { get componentViewChildren(): DebugElement[] {
var shadowView = this._parentView.getNestedView(this._boundElementIndex); var shadowView = this._parentView.getNestedView(this._boundElementIndex);
if (!isPresent(shadowView)) { if (!isPresent(shadowView)) {
@ -106,15 +106,15 @@ export class DebugElement {
* @param {Function: boolean} predicate * @param {Function: boolean} predicate
* @param {Scope} scope * @param {Scope} scope
* *
* @return {List<DebugElement>} * @return {DebugElement[]}
*/ */
queryAll(predicate: Predicate<DebugElement>, scope: Function = Scope.all): List<DebugElement> { queryAll(predicate: Predicate<DebugElement>, scope: Function = Scope.all): DebugElement[] {
var elementsInScope = scope(this); var elementsInScope = scope(this);
return ListWrapper.filter(elementsInScope, predicate); return ListWrapper.filter(elementsInScope, predicate);
} }
_getChildElements(view: AppView, parentBoundElementIndex: number): List<DebugElement> { _getChildElements(view: AppView, parentBoundElementIndex: number): DebugElement[] {
var els = []; var els = [];
var parentElementBinder = null; var parentElementBinder = null;
if (isPresent(parentBoundElementIndex)) { if (isPresent(parentBoundElementIndex)) {
@ -128,7 +128,7 @@ export class DebugElement {
var views = view.viewContainers[view.elementOffset + i]; var views = view.viewContainers[view.elementOffset + i];
if (isPresent(views)) { if (isPresent(views)) {
ListWrapper.forEach(views.views, (nextView) => { ListWrapper.forEach(views.views, (nextView) => {
els = ListWrapper.concat(els, this._getChildElements(nextView, null)); els = els.concat(this._getChildElements(nextView, null));
}); });
} }
} }
@ -141,38 +141,38 @@ export function inspectElement(elementRef: ElementRef): DebugElement {
return DebugElement.create(elementRef); return DebugElement.create(elementRef);
} }
export function asNativeElements(arr: List<DebugElement>): List<any> { export function asNativeElements(arr: DebugElement[]): any[] {
return arr.map((debugEl) => debugEl.nativeElement); return arr.map((debugEl) => debugEl.nativeElement);
} }
export class Scope { export class Scope {
static all(debugElement: DebugElement): List<DebugElement> { static all(debugElement: DebugElement): DebugElement[] {
var scope = []; var scope = [];
scope.push(debugElement); scope.push(debugElement);
ListWrapper.forEach(debugElement.children, ListWrapper.forEach(debugElement.children,
(child) => { scope = ListWrapper.concat(scope, Scope.all(child)); }); (child) => { scope = scope.concat(Scope.all(child)); });
ListWrapper.forEach(debugElement.componentViewChildren, ListWrapper.forEach(debugElement.componentViewChildren,
(child) => { scope = ListWrapper.concat(scope, Scope.all(child)); }); (child) => { scope = scope.concat(Scope.all(child)); });
return scope; return scope;
} }
static light(debugElement: DebugElement): List<DebugElement> { static light(debugElement: DebugElement): DebugElement[] {
var scope = []; var scope = [];
ListWrapper.forEach(debugElement.children, (child) => { ListWrapper.forEach(debugElement.children, (child) => {
scope.push(child); scope.push(child);
scope = ListWrapper.concat(scope, Scope.light(child)); scope = scope.concat(Scope.light(child));
}); });
return scope; return scope;
} }
static view(debugElement: DebugElement): List<DebugElement> { static view(debugElement: DebugElement): DebugElement[] {
var scope = []; var scope = [];
ListWrapper.forEach(debugElement.componentViewChildren, (child) => { ListWrapper.forEach(debugElement.componentViewChildren, (child) => {
scope.push(child); scope.push(child);
scope = ListWrapper.concat(scope, Scope.light(child)); scope = scope.concat(Scope.light(child));
}); });
return scope; return scope;
} }

View File

@ -1,5 +1,5 @@
import {CONST_EXPR, isPresent, NumberWrapper, StringWrapper} from 'angular2/src/core/facade/lang'; import {CONST_EXPR, isPresent, NumberWrapper, StringWrapper} from 'angular2/src/core/facade/lang';
import {MapWrapper, Map, ListWrapper, List} from 'angular2/src/core/facade/collection'; import {MapWrapper, Map, ListWrapper} from 'angular2/src/core/facade/collection';
import {Injectable, bind, Binding} from 'angular2/di'; import {Injectable, bind, Binding} from 'angular2/di';
import {AppViewListener} from 'angular2/src/core/compiler/view_listener'; import {AppViewListener} from 'angular2/src/core/compiler/view_listener';
import {AppView} from 'angular2/src/core/compiler/view'; import {AppView} from 'angular2/src/core/compiler/view';
@ -18,13 +18,13 @@ var _allViewsById = new Map<number, AppView>();
var _nextId = 0; var _nextId = 0;
function _setElementId(element, indices: List<number>) { function _setElementId(element, indices: number[]) {
if (isPresent(element)) { if (isPresent(element)) {
DOM.setData(element, NG_ID_PROPERTY, ListWrapper.join(indices, NG_ID_SEPARATOR)); DOM.setData(element, NG_ID_PROPERTY, ListWrapper.join(indices, NG_ID_SEPARATOR));
} }
} }
function _getElementId(element): List<number> { function _getElementId(element): number[] {
var elId = DOM.getData(element, NG_ID_PROPERTY); var elId = DOM.getData(element, NG_ID_PROPERTY);
if (isPresent(elId)) { if (isPresent(elId)) {
return ListWrapper.map(elId.split(NG_ID_SEPARATOR), return ListWrapper.map(elId.split(NG_ID_SEPARATOR),

View File

@ -8,7 +8,7 @@ import {
stringify, stringify,
isArray isArray
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {List, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {reflector} from 'angular2/src/core/reflection/reflection'; import {reflector} from 'angular2/src/core/reflection/reflection';
import {Key} from './key'; import {Key} from './key';
import { import {
@ -28,7 +28,7 @@ import {resolveForwardRef} from './forward_ref';
*/ */
export class Dependency { export class Dependency {
constructor(public key: Key, public optional: boolean, public lowerBoundVisibility: any, constructor(public key: Key, public optional: boolean, public lowerBoundVisibility: any,
public upperBoundVisibility: any, public properties: List<any>) {} public upperBoundVisibility: any, public properties: any[]) {}
static fromKey(key: Key): Dependency { return new Dependency(key, false, null, null, []); } static fromKey(key: Key): Dependency { return new Dependency(key, false, null, null, []); }
} }
@ -174,12 +174,12 @@ export class Binding {
* expect(injector.get(String)).toEqual('Value: 3'); * expect(injector.get(String)).toEqual('Value: 3');
* ``` * ```
*/ */
dependencies: List<any>; dependencies: any[];
constructor( constructor(
token, token,
{toClass, toValue, toAlias, toFactory, deps}: {toClass, toValue, toAlias, toFactory, deps}:
{toClass?: Type, toValue?: any, toAlias?: any, toFactory?: Function, deps?: List<any>}) { {toClass?: Type, toValue?: any, toAlias?: any, toFactory?: Function, deps?: any[]}) {
this.token = token; this.token = token;
this.toClass = toClass; this.toClass = toClass;
this.toValue = toValue; this.toValue = toValue;
@ -238,7 +238,7 @@ export class ResolvedBinding {
/** /**
* Arguments (dependencies) to the `factory` function. * Arguments (dependencies) to the `factory` function.
*/ */
public dependencies: List<Dependency>) {} public dependencies: Dependency[]) {}
} }
/** /**
@ -365,32 +365,30 @@ export class BindingBuilder {
* expect(injector.get(String)).toEqual('Value: 3'); * expect(injector.get(String)).toEqual('Value: 3');
* ``` * ```
*/ */
toFactory(factoryFunction: Function, dependencies?: List<any>): Binding { toFactory(factoryFunction: Function, dependencies?: any[]): Binding {
return new Binding(this.token, {toFactory: factoryFunction, deps: dependencies}); return new Binding(this.token, {toFactory: factoryFunction, deps: dependencies});
} }
} }
function _constructDependencies(factoryFunction: Function, dependencies: List<any>): function _constructDependencies(factoryFunction: Function, dependencies: any[]): Dependency[] {
List<Dependency> {
if (isBlank(dependencies)) { if (isBlank(dependencies)) {
return _dependenciesFor(factoryFunction); return _dependenciesFor(factoryFunction);
} else { } else {
var params: List<List<any>> = ListWrapper.map(dependencies, (t) => [t]); var params: any[][] = ListWrapper.map(dependencies, (t) => [t]);
return ListWrapper.map(dependencies, (t) => _extractToken(factoryFunction, t, params)); return ListWrapper.map(dependencies, (t) => _extractToken(factoryFunction, t, params));
} }
} }
function _dependenciesFor(typeOrFunc): List<Dependency> { function _dependenciesFor(typeOrFunc): Dependency[] {
var params = reflector.parameters(typeOrFunc); var params = reflector.parameters(typeOrFunc);
if (isBlank(params)) return []; if (isBlank(params)) return [];
if (ListWrapper.any(params, (p) => isBlank(p))) { if (ListWrapper.any(params, (p) => isBlank(p))) {
throw new NoAnnotationError(typeOrFunc, params); throw new NoAnnotationError(typeOrFunc, params);
} }
return ListWrapper.map(params, (p: List<any>) => _extractToken(typeOrFunc, p, params)); return ListWrapper.map(params, (p: any[]) => _extractToken(typeOrFunc, p, params));
} }
function _extractToken(typeOrFunc, metadata /*List<any> | any*/, params: List<List<any>>): function _extractToken(typeOrFunc, metadata /*any[] | any*/, params: any[][]): Dependency {
Dependency {
var depProps = []; var depProps = [];
var token = null; var token = null;
var optional = false; var optional = false;

View File

@ -1,9 +1,9 @@
import {ListWrapper, List} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {stringify, BaseException, isBlank} from 'angular2/src/core/facade/lang'; import {stringify, BaseException, isBlank} from 'angular2/src/core/facade/lang';
import {Key} from './key'; import {Key} from './key';
import {Injector} from './injector'; import {Injector} from './injector';
function findFirstClosedCycle(keys: List<any>): List<any> { function findFirstClosedCycle(keys: any[]): any[] {
var res = []; var res = [];
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; ++i) {
if (ListWrapper.contains(res, keys[i])) { if (ListWrapper.contains(res, keys[i])) {
@ -16,7 +16,7 @@ function findFirstClosedCycle(keys: List<any>): List<any> {
return res; return res;
} }
function constructResolvingPath(keys: List<any>): string { function constructResolvingPath(keys: any[]): string {
if (keys.length > 1) { if (keys.length > 1) {
var reversed = findFirstClosedCycle(ListWrapper.reversed(keys)); var reversed = findFirstClosedCycle(ListWrapper.reversed(keys));
var tokenStrs = ListWrapper.map(reversed, (k) => stringify(k.token)); var tokenStrs = ListWrapper.map(reversed, (k) => stringify(k.token));
@ -33,8 +33,8 @@ function constructResolvingPath(keys: List<any>): string {
export class AbstractBindingError extends BaseException { export class AbstractBindingError extends BaseException {
name: string; name: string;
message: string; message: string;
keys: List<Key>; keys: Key[];
injectors: List<Injector>; injectors: Injector[];
constructResolvingMessage: Function; constructResolvingMessage: Function;
constructor(injector: Injector, key: Key, constructResolvingMessage: Function, originalException?, constructor(injector: Injector, key: Key, constructResolvingMessage: Function, originalException?,
@ -63,7 +63,7 @@ export class AbstractBindingError extends BaseException {
*/ */
export class NoBindingError extends AbstractBindingError { export class NoBindingError extends AbstractBindingError {
constructor(injector: Injector, key: Key) { constructor(injector: Injector, key: Key) {
super(injector, key, function(keys: List<any>) { super(injector, key, function(keys: any[]) {
var first = stringify(ListWrapper.first(keys).token); var first = stringify(ListWrapper.first(keys).token);
return `No provider for ${first}!${constructResolvingPath(keys)}`; return `No provider for ${first}!${constructResolvingPath(keys)}`;
}); });
@ -88,7 +88,7 @@ export class NoBindingError extends AbstractBindingError {
*/ */
export class CyclicDependencyError extends AbstractBindingError { export class CyclicDependencyError extends AbstractBindingError {
constructor(injector: Injector, key: Key) { constructor(injector: Injector, key: Key) {
super(injector, key, function(keys: List<any>) { super(injector, key, function(keys: any[]) {
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`; return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
}); });
} }
@ -103,7 +103,7 @@ export class CyclicDependencyError extends AbstractBindingError {
export class InstantiationError extends AbstractBindingError { export class InstantiationError extends AbstractBindingError {
causeKey: Key; causeKey: Key;
constructor(injector: Injector, originalException, originalStack, key: Key) { constructor(injector: Injector, originalException, originalStack, key: Key) {
super(injector, key, function(keys: List<any>) { super(injector, key, function(keys: any[]) {
var first = stringify(ListWrapper.first(keys).token); var first = stringify(ListWrapper.first(keys).token);
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.`; return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.`;
}, originalException, originalStack); }, originalException, originalStack);
@ -136,7 +136,7 @@ export class InvalidBindingError extends BaseException {
export class NoAnnotationError extends BaseException { export class NoAnnotationError extends BaseException {
name: string; name: string;
message: string; message: string;
constructor(typeOrFunc, params: List<List<any>>) { constructor(typeOrFunc, params: any[][]) {
super(); super();
var signature = []; var signature = [];
for (var i = 0, ii = params.length; i < ii; i++) { for (var i = 0, ii = params.length; i < ii; i++) {

View File

@ -1,4 +1,4 @@
import {Map, List, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {ResolvedBinding, Binding, Dependency, BindingBuilder, bind} from './binding'; import {ResolvedBinding, Binding, Dependency, BindingBuilder, bind} from './binding';
import { import {
AbstractBindingError, AbstractBindingError,
@ -427,7 +427,7 @@ export class Injector {
*such as *such as
* `fromResolvedBindings` and `createChildFromResolved`. * `fromResolvedBindings` and `createChildFromResolved`.
*/ */
static resolve(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> { static resolve(bindings: Array<Type | Binding | any[]>): ResolvedBinding[] {
var resolvedBindings = _resolveBindings(bindings); var resolvedBindings = _resolveBindings(bindings);
var flatten = _flattenBindings(resolvedBindings, new Map()); var flatten = _flattenBindings(resolvedBindings, new Map());
return _createListOfBindings(flatten); return _createListOfBindings(flatten);
@ -446,7 +446,7 @@ export class Injector {
* bindings. * bindings.
* @param `depProvider` * @param `depProvider`
*/ */
static resolveAndCreate(bindings: List<Type | Binding | List<any>>, static resolveAndCreate(bindings: Array<Type | Binding | any[]>,
depProvider: DependencyProvider = null): Injector { depProvider: DependencyProvider = null): Injector {
var resolvedBindings = Injector.resolve(bindings); var resolvedBindings = Injector.resolve(bindings);
return Injector.fromResolvedBindings(resolvedBindings, depProvider); return Injector.fromResolvedBindings(resolvedBindings, depProvider);
@ -460,7 +460,7 @@ export class Injector {
* {@link Injector}. * {@link Injector}.
* @param `depProvider` * @param `depProvider`
*/ */
static fromResolvedBindings(bindings: List<ResolvedBinding>, static fromResolvedBindings(bindings: ResolvedBinding[],
depProvider: DependencyProvider = null): Injector { depProvider: DependencyProvider = null): Injector {
var bd = bindings.map(b => new BindingWithVisibility(b, Visibility.Public)); var bd = bindings.map(b => new BindingWithVisibility(b, Visibility.Public));
var proto = new ProtoInjector(bd); var proto = new ProtoInjector(bd);
@ -537,7 +537,7 @@ export class Injector {
* recursive list of more bindings. * recursive list of more bindings.
* @param `depProvider` * @param `depProvider`
*/ */
resolveAndCreateChild(bindings: List<Type | Binding | List<any>>, resolveAndCreateChild(bindings: Array<Type | Binding | any[]>,
depProvider: DependencyProvider = null): Injector { depProvider: DependencyProvider = null): Injector {
var resovledBindings = Injector.resolve(bindings); var resovledBindings = Injector.resolve(bindings);
return this.createChildFromResolved(resovledBindings, depProvider); return this.createChildFromResolved(resovledBindings, depProvider);
@ -551,7 +551,7 @@ export class Injector {
* @param `depProvider` * @param `depProvider`
* @returns a new child {@link Injector}. * @returns a new child {@link Injector}.
*/ */
createChildFromResolved(bindings: List<ResolvedBinding>, createChildFromResolved(bindings: ResolvedBinding[],
depProvider: DependencyProvider = null): Injector { depProvider: DependencyProvider = null): Injector {
var bd = bindings.map(b => new BindingWithVisibility(b, Visibility.Public)); var bd = bindings.map(b => new BindingWithVisibility(b, Visibility.Public));
var proto = new ProtoInjector(bd); var proto = new ProtoInjector(bd);
@ -801,7 +801,7 @@ export class Injector {
var INJECTOR_KEY = Key.get(Injector); var INJECTOR_KEY = Key.get(Injector);
function _resolveBindings(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> { function _resolveBindings(bindings: Array<Type | Binding | any[]>): ResolvedBinding[] {
var resolvedList = ListWrapper.createFixedSize(bindings.length); var resolvedList = ListWrapper.createFixedSize(bindings.length);
for (var i = 0; i < bindings.length; i++) { for (var i = 0; i < bindings.length; i++) {
var unresolved = resolveForwardRef(bindings[i]); var unresolved = resolveForwardRef(bindings[i]);
@ -812,7 +812,7 @@ function _resolveBindings(bindings: List<Type | Binding | List<any>>): List<Reso
resolved = bind(unresolved).toClass(unresolved).resolve(); resolved = bind(unresolved).toClass(unresolved).resolve();
} else if (unresolved instanceof Binding) { } else if (unresolved instanceof Binding) {
resolved = unresolved.resolve(); resolved = unresolved.resolve();
} else if (unresolved instanceof List) { } else if (unresolved instanceof Array) {
resolved = _resolveBindings(unresolved); resolved = _resolveBindings(unresolved);
} else if (unresolved instanceof BindingBuilder) { } else if (unresolved instanceof BindingBuilder) {
throw new InvalidBindingError(unresolved.token); throw new InvalidBindingError(unresolved.token);
@ -824,17 +824,16 @@ function _resolveBindings(bindings: List<Type | Binding | List<any>>): List<Reso
return resolvedList; return resolvedList;
} }
function _createListOfBindings(flattenedBindings: Map<number, ResolvedBinding>): function _createListOfBindings(flattenedBindings: Map<number, ResolvedBinding>): ResolvedBinding[] {
List<ResolvedBinding> {
return MapWrapper.values(flattenedBindings); return MapWrapper.values(flattenedBindings);
} }
function _flattenBindings(bindings: List<ResolvedBinding | List<any>>, function _flattenBindings(bindings: Array<ResolvedBinding | any[]>,
res: Map<number, ResolvedBinding>): Map<number, ResolvedBinding> { res: Map<number, ResolvedBinding>): Map<number, ResolvedBinding> {
ListWrapper.forEach(bindings, function(b) { ListWrapper.forEach(bindings, function(b) {
if (b instanceof ResolvedBinding) { if (b instanceof ResolvedBinding) {
res.set(b.key.id, b); res.set(b.key.id, b);
} else if (b instanceof List) { } else if (b instanceof Array) {
_flattenBindings(b, res); _flattenBindings(b, res);
} }
}); });

View File

@ -83,8 +83,7 @@ export class NgFor {
view.setLocal('index', record.currentIndex); view.setLocal('index', record.currentIndex);
} }
static bulkRemove(tuples: List<RecordViewTuple>, static bulkRemove(tuples: RecordViewTuple[], viewContainer: ViewContainerRef): RecordViewTuple[] {
viewContainer: ViewContainerRef): List<RecordViewTuple> {
tuples.sort((a, b) => a.record.previousIndex - b.record.previousIndex); tuples.sort((a, b) => a.record.previousIndex - b.record.previousIndex);
var movedTuples = []; var movedTuples = [];
for (var i = tuples.length - 1; i >= 0; i--) { for (var i = tuples.length - 1; i >= 0; i--) {
@ -100,8 +99,8 @@ export class NgFor {
return movedTuples; return movedTuples;
} }
static bulkInsert(tuples: List<RecordViewTuple>, viewContainer: ViewContainerRef, static bulkInsert(tuples: RecordViewTuple[], viewContainer: ViewContainerRef,
templateRef: TemplateRef): List<RecordViewTuple> { templateRef: TemplateRef): RecordViewTuple[] {
tuples.sort((a, b) => a.record.currentIndex - b.record.currentIndex); tuples.sort((a, b) => a.record.currentIndex - b.record.currentIndex);
for (var i = 0; i < tuples.length; i++) { for (var i = 0; i < tuples.length; i++) {
var tuple = tuples[i]; var tuple = tuples[i];

View File

@ -2,7 +2,7 @@ import {Directive} from 'angular2/metadata';
import {Host} from 'angular2/di'; import {Host} from 'angular2/di';
import {ViewContainerRef, TemplateRef} from 'angular2/core'; import {ViewContainerRef, TemplateRef} from 'angular2/core';
import {isPresent, isBlank, normalizeBlank, CONST_EXPR} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, normalizeBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';
import {ListWrapper, List, Map} from 'angular2/src/core/facade/collection'; import {ListWrapper, Map} from 'angular2/src/core/facade/collection';
const _WHEN_DEFAULT = CONST_EXPR(new Object()); const _WHEN_DEFAULT = CONST_EXPR(new Object());
@ -43,8 +43,8 @@ export class SwitchView {
export class NgSwitch { export class NgSwitch {
private _switchValue: any; private _switchValue: any;
private _useDefault: boolean = false; private _useDefault: boolean = false;
private _valueViews: Map<any, List<SwitchView>> = new Map(); private _valueViews: Map<any, SwitchView[]> = new Map();
private _activeViews: List<SwitchView> = []; private _activeViews: SwitchView[] = [];
set ngSwitch(value) { set ngSwitch(value) {
// Empty the currently active ViewContainers // Empty the currently active ViewContainers
@ -93,7 +93,7 @@ export class NgSwitch {
this._activeViews = []; this._activeViews = [];
} }
_activateViews(views: List<SwitchView>): void { _activateViews(views: SwitchView[]): void {
// TODO(vicb): assert(this._activeViews.length === 0); // TODO(vicb): assert(this._activeViews.length === 0);
if (isPresent(views)) { if (isPresent(views)) {
for (var i = 0; i < views.length; i++) { for (var i = 0; i < views.length; i++) {

View File

@ -1,4 +1,4 @@
import {List, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {isBlank, isPresent, global, setValueOnPath} from 'angular2/src/core/facade/lang'; import {isBlank, isPresent, global, setValueOnPath} from 'angular2/src/core/facade/lang';
import {setRootDomAdapter} from './dom_adapter'; import {setRootDomAdapter} from './dom_adapter';
import {GenericBrowserDomAdapter} from './generic_browser_adapter'; import {GenericBrowserDomAdapter} from './generic_browser_adapter';
@ -59,7 +59,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
hasProperty(element, name: string): boolean { return name in element; } hasProperty(element, name: string): boolean { return name in element; }
setProperty(el: /*element*/ any, name: string, value: any) { el[name] = value; } setProperty(el: /*element*/ any, name: string, value: any) { el[name] = value; }
getProperty(el: /*element*/ any, name: string): any { return el[name]; } getProperty(el: /*element*/ any, name: string): any { return el[name]; }
invoke(el: /*element*/ any, methodName: string, args: List<any>): any { invoke(el: /*element*/ any, methodName: string, args: any[]): any {
el[methodName].apply(el, args); el[methodName].apply(el, args);
} }
@ -93,7 +93,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
query(selector: string): any { return document.querySelector(selector); } query(selector: string): any { return document.querySelector(selector); }
querySelector(el, selector: string): HTMLElement { return el.querySelector(selector); } querySelector(el, selector: string): HTMLElement { return el.querySelector(selector); }
querySelectorAll(el, selector: string): List<any> { return el.querySelectorAll(selector); } querySelectorAll(el, selector: string): any[] { return el.querySelectorAll(selector); }
on(el, evt, listener) { el.addEventListener(evt, listener, false); } on(el, evt, listener) { el.addEventListener(evt, listener, false); }
onAndCancel(el, evt, listener): Function { onAndCancel(el, evt, listener): Function {
el.addEventListener(evt, listener, false); el.addEventListener(evt, listener, false);
@ -134,8 +134,8 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
firstChild(el): Node { return el.firstChild; } firstChild(el): Node { return el.firstChild; }
nextSibling(el): Node { return el.nextSibling; } nextSibling(el): Node { return el.nextSibling; }
parentElement(el): Node { return el.parentNode; } parentElement(el): Node { return el.parentNode; }
childNodes(el): List<Node> { return el.childNodes; } childNodes(el): Node[] { return el.childNodes; }
childNodesAsList(el): List<any> { childNodesAsList(el): any[] {
var childNodes = el.childNodes; var childNodes = el.childNodes;
var res = ListWrapper.createFixedSize(childNodes.length); var res = ListWrapper.createFixedSize(childNodes.length);
for (var i = 0; i < childNodes.length; i++) { for (var i = 0; i < childNodes.length; i++) {
@ -190,15 +190,13 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
getShadowRoot(el: HTMLElement): DocumentFragment { return (<any>el).shadowRoot; } getShadowRoot(el: HTMLElement): DocumentFragment { return (<any>el).shadowRoot; }
getHost(el: HTMLElement): HTMLElement { return (<any>el).host; } getHost(el: HTMLElement): HTMLElement { return (<any>el).host; }
clone(node: Node): Node { return node.cloneNode(true); } clone(node: Node): Node { return node.cloneNode(true); }
getElementsByClassName(element, name: string): List<HTMLElement> { getElementsByClassName(element, name: string): HTMLElement[] {
return element.getElementsByClassName(name); return element.getElementsByClassName(name);
} }
getElementsByTagName(element, name: string): List<HTMLElement> { getElementsByTagName(element, name: string): HTMLElement[] {
return element.getElementsByTagName(name); return element.getElementsByTagName(name);
} }
classList(element): List<any> { classList(element): any[] { return <any[]>Array.prototype.slice.call(element.classList, 0); }
return <List<any>>Array.prototype.slice.call(element.classList, 0);
}
addClass(element, classname: string) { element.classList.add(classname); } addClass(element, classname: string) { element.classList.add(classname); }
removeClass(element, classname: string) { element.classList.remove(classname); } removeClass(element, classname: string) { element.classList.remove(classname); }
hasClass(element, classname: string): boolean { return element.classList.contains(classname); } hasClass(element, classname: string): boolean { return element.classList.contains(classname); }

View File

@ -22,7 +22,7 @@ export class DomAdapter {
hasProperty(element, name: string): boolean { throw _abstract(); } hasProperty(element, name: string): boolean { throw _abstract(); }
setProperty(el: Element, name: string, value: any) { throw _abstract(); } setProperty(el: Element, name: string, value: any) { throw _abstract(); }
getProperty(el: Element, name: string): any { throw _abstract(); } getProperty(el: Element, name: string): any { throw _abstract(); }
invoke(el: Element, methodName: string, args: List<any>): any { throw _abstract(); } invoke(el: Element, methodName: string, args: any[]): any { throw _abstract(); }
logError(error) { throw _abstract(); } logError(error) { throw _abstract(); }
log(error) { throw _abstract(); } log(error) { throw _abstract(); }
@ -38,7 +38,7 @@ export class DomAdapter {
parse(templateHtml: string) { throw _abstract(); } parse(templateHtml: string) { throw _abstract(); }
query(selector: string): any { throw _abstract(); } query(selector: string): any { throw _abstract(); }
querySelector(el, selector: string): HTMLElement { throw _abstract(); } querySelector(el, selector: string): HTMLElement { throw _abstract(); }
querySelectorAll(el, selector: string): List<any> { throw _abstract(); } querySelectorAll(el, selector: string): any[] { throw _abstract(); }
on(el, evt, listener) { throw _abstract(); } on(el, evt, listener) { throw _abstract(); }
onAndCancel(el, evt, listener): Function { throw _abstract(); } onAndCancel(el, evt, listener): Function { throw _abstract(); }
dispatchEvent(el, evt) { throw _abstract(); } dispatchEvent(el, evt) { throw _abstract(); }
@ -55,8 +55,8 @@ export class DomAdapter {
firstChild(el): Node { throw _abstract(); } firstChild(el): Node { throw _abstract(); }
nextSibling(el): Node { throw _abstract(); } nextSibling(el): Node { throw _abstract(); }
parentElement(el): Node { throw _abstract(); } parentElement(el): Node { throw _abstract(); }
childNodes(el): List<Node> { throw _abstract(); } childNodes(el): Node[] { throw _abstract(); }
childNodesAsList(el): List<Node> { throw _abstract(); } childNodesAsList(el): Node[] { throw _abstract(); }
clearNodes(el) { throw _abstract(); } clearNodes(el) { throw _abstract(); }
appendChild(el, node) { throw _abstract(); } appendChild(el, node) { throw _abstract(); }
removeChild(el, node) { throw _abstract(); } removeChild(el, node) { throw _abstract(); }
@ -83,11 +83,11 @@ export class DomAdapter {
createShadowRoot(el): any { throw _abstract(); } createShadowRoot(el): any { throw _abstract(); }
getShadowRoot(el): any { throw _abstract(); } getShadowRoot(el): any { throw _abstract(); }
getHost(el): any { throw _abstract(); } getHost(el): any { throw _abstract(); }
getDistributedNodes(el): List<Node> { throw _abstract(); } getDistributedNodes(el): Node[] { throw _abstract(); }
clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); } clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
getElementsByClassName(element, name: string): List<HTMLElement> { throw _abstract(); } getElementsByClassName(element, name: string): HTMLElement[] { throw _abstract(); }
getElementsByTagName(element, name: string): List<HTMLElement> { throw _abstract(); } getElementsByTagName(element, name: string): HTMLElement[] { throw _abstract(); }
classList(element): List<any> { throw _abstract(); } classList(element): any[] { throw _abstract(); }
addClass(element, classname: string) { throw _abstract(); } addClass(element, classname: string) { throw _abstract(); }
removeClass(element, classname: string) { throw _abstract(); } removeClass(element, classname: string) { throw _abstract(); }
hasClass(element, classname: string): boolean { throw _abstract(); } hasClass(element, classname: string): boolean { throw _abstract(); }
@ -122,7 +122,7 @@ export class DomAdapter {
getHref(element): string { throw _abstract(); } getHref(element): string { throw _abstract(); }
getEventKey(event): string { throw _abstract(); } getEventKey(event): string { throw _abstract(); }
resolveAndSetHref(element, baseUrl: string, href: string) { throw _abstract(); } resolveAndSetHref(element, baseUrl: string, href: string) { throw _abstract(); }
cssToRules(css: string): List<any> { throw _abstract(); } cssToRules(css: string): any[] { throw _abstract(); }
supportsDOMEvents(): boolean { throw _abstract(); } supportsDOMEvents(): boolean { throw _abstract(); }
supportsNativeShadowDOM(): boolean { throw _abstract(); } supportsNativeShadowDOM(): boolean { throw _abstract(); }
getGlobalEventTarget(target: string): any { throw _abstract(); } getGlobalEventTarget(target: string): any { throw _abstract(); }

View File

@ -1,4 +1,4 @@
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {isPresent, isFunction} from 'angular2/src/core/facade/lang'; import {isPresent, isFunction} from 'angular2/src/core/facade/lang';
import {DomAdapter} from './dom_adapter'; import {DomAdapter} from './dom_adapter';
@ -6,11 +6,11 @@ import {DomAdapter} from './dom_adapter';
* Provides DOM operations in any browser environment. * Provides DOM operations in any browser environment.
*/ */
export class GenericBrowserDomAdapter extends DomAdapter { export class GenericBrowserDomAdapter extends DomAdapter {
getDistributedNodes(el: HTMLElement): List<Node> { return (<any>el).getDistributedNodes(); } getDistributedNodes(el: HTMLElement): Node[] { return (<any>el).getDistributedNodes(); }
resolveAndSetHref(el: HTMLAnchorElement, baseUrl: string, href: string) { resolveAndSetHref(el: HTMLAnchorElement, baseUrl: string, href: string) {
el.href = href == null ? baseUrl : baseUrl + '/../' + href; el.href = href == null ? baseUrl : baseUrl + '/../' + href;
} }
cssToRules(css: string): List<any> { cssToRules(css: string): any[] {
var style = this.createStyleElement(css); var style = this.createStyleElement(css);
this.appendChild(this.defaultDoc().head, style); this.appendChild(this.defaultDoc().head, style);
var rules = []; var rules = [];

View File

@ -7,7 +7,7 @@ var cssParse = require('css').parse;
var url = require('url'); var url = require('url');
import {List, MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {DomAdapter, setRootDomAdapter} from './dom_adapter'; import {DomAdapter, setRootDomAdapter} from './dom_adapter';
import { import {
BaseException, BaseException,
@ -66,7 +66,7 @@ export class Parse5DomAdapter extends DomAdapter {
query(selector) { throw _notImplemented('query'); } query(selector) { throw _notImplemented('query'); }
querySelector(el, selector: string): any { return this.querySelectorAll(el, selector)[0]; } querySelector(el, selector: string): any { return this.querySelectorAll(el, selector)[0]; }
querySelectorAll(el, selector: string): List<any> { querySelectorAll(el, selector: string): any[] {
var res = []; var res = [];
var _recursive = (result, node, selector, matcher) => { var _recursive = (result, node, selector, matcher) => {
var cNodes = node.childNodes; var cNodes = node.childNodes;
@ -131,7 +131,7 @@ export class Parse5DomAdapter extends DomAdapter {
onAndCancel(el, evt, listener): Function { onAndCancel(el, evt, listener): Function {
this.on(el, evt, listener); this.on(el, evt, listener);
return () => { return () => {
ListWrapper.remove(StringMapWrapper.get<List<any>>(el._eventListenersMap, evt), listener); ListWrapper.remove(StringMapWrapper.get<any[]>(el._eventListenersMap, evt), listener);
}; };
} }
dispatchEvent(el, evt) { dispatchEvent(el, evt) {
@ -178,7 +178,7 @@ export class Parse5DomAdapter extends DomAdapter {
nextSibling(el): Node { return el.nextSibling; } nextSibling(el): Node { return el.nextSibling; }
parentElement(el): Node { return el.parent; } parentElement(el): Node { return el.parent; }
childNodes(el): Node[] { return el.childNodes; } childNodes(el): Node[] { return el.childNodes; }
childNodesAsList(el): List<any> { childNodesAsList(el): any[] {
var childNodes = el.childNodes; var childNodes = el.childNodes;
var res = ListWrapper.createFixedSize(childNodes.length); var res = ListWrapper.createFixedSize(childNodes.length);
for (var i = 0; i < childNodes.length; i++) { for (var i = 0; i < childNodes.length; i++) {
@ -292,7 +292,7 @@ export class Parse5DomAdapter extends DomAdapter {
} }
getShadowRoot(el): Element { return el.shadowRoot; } getShadowRoot(el): Element { return el.shadowRoot; }
getHost(el): string { return el.host; } getHost(el): string { return el.host; }
getDistributedNodes(el: any): List<Node> { throw _notImplemented('getDistributedNodes'); } getDistributedNodes(el: any): Node[] { throw _notImplemented('getDistributedNodes'); }
clone(node: Node): Node { clone(node: Node): Node {
var _recursive = (node) => { var _recursive = (node) => {
var nodeClone = Object.create(Object.getPrototypeOf(node)); var nodeClone = Object.create(Object.getPrototypeOf(node));
@ -334,13 +334,13 @@ export class Parse5DomAdapter extends DomAdapter {
}; };
return _recursive(node); return _recursive(node);
} }
getElementsByClassName(element, name: string): List<HTMLElement> { getElementsByClassName(element, name: string): HTMLElement[] {
return this.querySelectorAll(element, "." + name); return this.querySelectorAll(element, "." + name);
} }
getElementsByTagName(element: any, name: string): List<HTMLElement> { getElementsByTagName(element: any, name: string): HTMLElement[] {
throw _notImplemented('getElementsByTagName'); throw _notImplemented('getElementsByTagName');
} }
classList(element): List<string> { classList(element): string[] {
var classAttrValue = null; var classAttrValue = null;
var attributes = element.attribs; var attributes = element.attribs;
if (attributes && attributes.hasOwnProperty("class")) { if (attributes && attributes.hasOwnProperty("class")) {
@ -518,7 +518,7 @@ export class Parse5DomAdapter extends DomAdapter {
} }
return rules; return rules;
} }
cssToRules(css: string): List<any> { cssToRules(css: string): any[] {
css = css.replace(/url\(\'(.+)\'\)/g, 'url($1)'); css = css.replace(/url\(\'(.+)\'\)/g, 'url($1)');
var rules = []; var rules = [];
var parsedCSS = cssParse(css, {silent: true}); var parsedCSS = cssParse(css, {silent: true});

View File

@ -1,7 +1,6 @@
/// <reference path="../../../typings/rx/rx.d.ts" /> /// <reference path="../../../typings/rx/rx.d.ts" />
import {global, isPresent} from 'angular2/src/core/facade/lang'; import {global, isPresent} from 'angular2/src/core/facade/lang';
import {List} from 'angular2/src/core/facade/collection';
import * as Rx from 'rx'; import * as Rx from 'rx';
export {Promise}; export {Promise};
@ -24,7 +23,7 @@ export class PromiseWrapper {
return promise.catch(onError); return promise.catch(onError);
} }
static all(promises: List<any>): Promise<any> { static all(promises: any[]): Promise<any> {
if (promises.length == 0) return Promise.resolve([]); if (promises.length == 0) return Promise.resolve([]);
return Promise.all(promises); return Promise.all(promises);
} }

View File

@ -115,10 +115,6 @@ class ListWrapper {
static List createFixedSize(int size) => new List(size); static List createFixedSize(int size) => new List(size);
static List createGrowableSize(int size) => static List createGrowableSize(int size) =>
new List.generate(size, (_) => null, growable: true); new List.generate(size, (_) => null, growable: true);
static get(List m, int k) => m[k];
static void set(List m, int k, v) {
m[k] = v;
}
static bool contains(List m, k) => m.contains(k); static bool contains(List m, k) => m.contains(k);
static List map(list, fn(item)) => list.map(fn).toList(); static List map(list, fn(item)) => list.map(fn).toList();

View File

@ -1,21 +1,19 @@
import {isJsObject, global, isPresent, isBlank, isArray} from 'angular2/src/core/facade/lang'; import {isJsObject, global, isPresent, isBlank, isArray} from 'angular2/src/core/facade/lang';
export var List = global.Array;
export var Map = global.Map; export var Map = global.Map;
export var Set = global.Set; export var Set = global.Set;
export var StringMap = global.Object; export var StringMap = global.Object;
// Safari and Internet Explorer do not support the iterable parameter to the // Safari and Internet Explorer do not support the iterable parameter to the
// Map constructor. We work around that by manually adding the items. // Map constructor. We work around that by manually adding the items.
var createMapFromPairs: {(pairs: List<any>): Map<any, any>} = (function() { var createMapFromPairs: {(pairs: any[]): Map<any, any>} = (function() {
try { try {
if (new Map([[1, 2]]).size === 1) { if (new Map([[1, 2]]).size === 1) {
return function createMapFromPairs(pairs: List<any>): return function createMapFromPairs(pairs: any[]): Map<any, any> { return new Map(pairs); };
Map<any, any> { return new Map(pairs); };
} }
} catch (e) { } catch (e) {
} }
return function createMapAndPopulateFromPairs(pairs: List<any>): Map<any, any> { return function createMapAndPopulateFromPairs(pairs: any[]): Map<any, any> {
var map = new Map(); var map = new Map();
for (var i = 0; i < pairs.length; i++) { for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i]; var pair = pairs[i];
@ -54,19 +52,18 @@ var _clearValues: {(m: Map<any, any>)} = (function() {
})(); })();
// Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from // Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from
// TODO(mlaval): remove the work around once we have a working polyfill of Array.from // TODO(mlaval): remove the work around once we have a working polyfill of Array.from
var _arrayFromMap: {(m: Map<any, any>, getValues: boolean): List<any>} = (function() { var _arrayFromMap: {(m: Map<any, any>, getValues: boolean): any[]} = (function() {
try { try {
if ((<any>(new Map()).values()).next) { if ((<any>(new Map()).values()).next) {
return function createArrayFromMap(m: Map<any, any>, getValues: boolean): List<any> { return function createArrayFromMap(m: Map<any, any>, getValues: boolean):
return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys()); any[] { return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys()); };
};
} }
} catch (e) { } catch (e) {
} }
return function createArrayFromMapWithForeach(m: Map<any, any>, getValues: boolean): List<any> { return function createArrayFromMapWithForeach(m: Map<any, any>, getValues: boolean): any[] {
var res = ListWrapper.createFixedSize(m.size), i = 0; var res = ListWrapper.createFixedSize(m.size), i = 0;
m.forEach((v, k) => { m.forEach((v, k) => {
ListWrapper.set(res, i, getValues ? v : k); res[i] = getValues ? v : k;
i++; i++;
}); });
return res; return res;
@ -87,15 +84,15 @@ export class MapWrapper {
m.forEach((v, k) => r[k] = v); m.forEach((v, k) => r[k] = v);
return r; return r;
} }
static createFromPairs(pairs: List<any>): Map<any, any> { return createMapFromPairs(pairs); } static createFromPairs(pairs: any[]): Map<any, any> { return createMapFromPairs(pairs); }
static forEach<K, V>(m: Map<K, V>, fn: /*(V, K) => void*/ Function) { m.forEach(<any>fn); } static forEach<K, V>(m: Map<K, V>, fn: /*(V, K) => void*/ Function) { m.forEach(<any>fn); }
static get<K, V>(map: Map<K, V>, key: K): V { return map.get(key); } static get<K, V>(map: Map<K, V>, key: K): V { return map.get(key); }
static size(m: Map<any, any>): number { return m.size; } static size(m: Map<any, any>): number { return m.size; }
static delete<K>(m: Map<K, any>, k: K) { m.delete(k); } static delete<K>(m: Map<K, any>, k: K) { m.delete(k); }
static clearValues(m: Map<any, any>) { _clearValues(m); } static clearValues(m: Map<any, any>) { _clearValues(m); }
static iterable<T>(m: T): T { return m; } static iterable<T>(m: T): T { return m; }
static keys<K>(m: Map<K, any>): List<K> { return _arrayFromMap(m, false); } static keys<K>(m: Map<K, any>): K[] { return _arrayFromMap(m, false); }
static values<V>(m: Map<any, V>): List<V> { return _arrayFromMap(m, true); } static values<V>(m: Map<any, V>): V[] { return _arrayFromMap(m, true); }
} }
/** /**
@ -115,7 +112,7 @@ export class StringMapWrapper {
return map.hasOwnProperty(key) ? map[key] : undefined; return map.hasOwnProperty(key) ? map[key] : undefined;
} }
static set<V>(map: StringMap<string, V>, key: string, value: V) { map[key] = value; } static set<V>(map: StringMap<string, V>, key: string, value: V) { map[key] = value; }
static keys(map: StringMap<string, any>): List<string> { return Object.keys(map); } static keys(map: StringMap<string, any>): string[] { return Object.keys(map); }
static isEmpty(map: StringMap<string, any>): boolean { static isEmpty(map: StringMap<string, any>): boolean {
for (var prop in map) { for (var prop in map) {
return false; return false;
@ -171,71 +168,69 @@ export interface Predicate<T> { (value: T, index?: number, array?: T[]): boolean
export class ListWrapper { export class ListWrapper {
// JS has no way to express a staticly fixed size list, but dart does so we // JS has no way to express a staticly fixed size list, but dart does so we
// keep both methods. // keep both methods.
static createFixedSize(size: number): List<any> { return new List(size); } static createFixedSize(size: number): any[] { return new Array(size); }
static createGrowableSize(size: number): List<any> { return new List(size); } static createGrowableSize(size: number): any[] { return new Array(size); }
static get<T>(m: List<T>, k: number): T { return m[k]; } static clone<T>(array: T[]): T[] { return array.slice(0); }
static set<T>(m: List<T>, k: number, v: T) { m[k] = v; } static map<T, V>(array: T[], fn: (T) => V): V[] { return array.map(fn); }
static clone<T>(array: List<T>): T[] { return array.slice(0); } static forEach<T>(array: T[], fn: (T) => void) {
static map<T, V>(array: List<T>, fn: (T) => V): List<V> { return array.map(fn); }
static forEach<T>(array: List<T>, fn: (T) => void) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
fn(array[i]); fn(array[i]);
} }
} }
static forEachWithIndex<T>(array: List<T>, fn: (T, number) => void) { static forEachWithIndex<T>(array: T[], fn: (T, number) => void) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
fn(array[i], i); fn(array[i], i);
} }
} }
static first<T>(array: List<T>): T { static first<T>(array: T[]): T {
if (!array) return null; if (!array) return null;
return array[0]; return array[0];
} }
static last<T>(array: List<T>): T { static last<T>(array: T[]): T {
if (!array || array.length == 0) return null; if (!array || array.length == 0) return null;
return array[array.length - 1]; return array[array.length - 1];
} }
static find<T>(list: List<T>, pred: Predicate<T>): T { static find<T>(list: T[], pred: Predicate<T>): T {
for (var i = 0; i < list.length; ++i) { for (var i = 0; i < list.length; ++i) {
if (pred(list[i])) return list[i]; if (pred(list[i])) return list[i];
} }
return null; return null;
} }
static indexOf<T>(array: List<T>, value: T, startIndex: number = 0): number { static indexOf<T>(array: T[], value: T, startIndex: number = 0): number {
return array.indexOf(value, startIndex); return array.indexOf(value, startIndex);
} }
static reduce<T, E>(list: List<T>, static reduce<T, E>(list: T[],
fn: (accumValue: E, currentValue: T, currentIndex: number, array: T[]) => E, fn: (accumValue: E, currentValue: T, currentIndex: number, array: T[]) => E,
init: E): E { init: E): E {
return list.reduce(fn, init); return list.reduce(fn, init);
} }
static filter<T>(array: List<T>, pred: Predicate<T>): T[] { return array.filter(pred); } static filter<T>(array: T[], pred: Predicate<T>): T[] { return array.filter(pred); }
static any(list: List<any>, pred: Function): boolean { static any(list: any[], pred: Function): boolean {
for (var i = 0; i < list.length; ++i) { for (var i = 0; i < list.length; ++i) {
if (pred(list[i])) return true; if (pred(list[i])) return true;
} }
return false; return false;
} }
static contains<T>(list: List<T>, el: T): boolean { return list.indexOf(el) !== -1; } static contains<T>(list: T[], el: T): boolean { return list.indexOf(el) !== -1; }
static reversed<T>(array: List<T>): T[] { static reversed<T>(array: T[]): T[] {
var a = ListWrapper.clone(array); var a = ListWrapper.clone(array);
return a.reverse(); return a.reverse();
} }
static concat(a: List<any>, b: List<any>): List<any> { return a.concat(b); } static concat(a: any[], b: any[]): any[] { return a.concat(b); }
static insert<T>(list: List<T>, index: number, value: T) { list.splice(index, 0, value); } static insert<T>(list: T[], index: number, value: T) { list.splice(index, 0, value); }
static removeAt<T>(list: List<T>, index: number): T { static removeAt<T>(list: T[], index: number): T {
var res = list[index]; var res = list[index];
list.splice(index, 1); list.splice(index, 1);
return res; return res;
} }
static removeAll<T>(list: List<T>, items: List<T>) { static removeAll<T>(list: T[], items: T[]) {
for (var i = 0; i < items.length; ++i) { for (var i = 0; i < items.length; ++i) {
var index = list.indexOf(items[i]); var index = list.indexOf(items[i]);
list.splice(index, 1); list.splice(index, 1);
} }
} }
static removeLast<T>(list: List<T>): T { return list.pop(); } static removeLast<T>(list: T[]): T { return list.pop(); }
static remove<T>(list: List<T>, el: T): boolean { static remove<T>(list: T[], el: T): boolean {
var index = list.indexOf(el); var index = list.indexOf(el);
if (index > -1) { if (index > -1) {
list.splice(index, 1); list.splice(index, 1);
@ -243,36 +238,34 @@ export class ListWrapper {
} }
return false; return false;
} }
static clear(list: List<any>) { list.splice(0, list.length); } static clear(list: any[]) { list.splice(0, list.length); }
static join(list: List<any>, s: string): string { return list.join(s); } static join(list: any[], s: string): string { return list.join(s); }
static isEmpty(list: List<any>): boolean { return list.length == 0; } static isEmpty(list: any[]): boolean { return list.length == 0; }
static fill(list: List<any>, value: any, start: number = 0, end: number = null) { static fill(list: any[], value: any, start: number = 0, end: number = null) {
list.fill(value, start, end === null ? list.length : end); list.fill(value, start, end === null ? list.length : end);
} }
static equals(a: List<any>, b: List<any>): boolean { static equals(a: any[], b: any[]): boolean {
if (a.length != b.length) return false; if (a.length != b.length) return false;
for (var i = 0; i < a.length; ++i) { for (var i = 0; i < a.length; ++i) {
if (a[i] !== b[i]) return false; if (a[i] !== b[i]) return false;
} }
return true; return true;
} }
static slice<T>(l: List<T>, from: number = 0, to: number = null): List<T> { static slice<T>(l: T[], from: number = 0, to: number = null): T[] {
return l.slice(from, to === null ? undefined : to); return l.slice(from, to === null ? undefined : to);
} }
static splice<T>(l: List<T>, from: number, length: number): List<T> { static splice<T>(l: T[], from: number, length: number): T[] { return l.splice(from, length); }
return l.splice(from, length); static sort<T>(l: T[], compareFn?: (a: T, b: T) => number) {
}
static sort<T>(l: List<T>, compareFn?: (a: T, b: T) => number) {
if (isPresent(compareFn)) { if (isPresent(compareFn)) {
l.sort(compareFn); l.sort(compareFn);
} else { } else {
l.sort(); l.sort();
} }
} }
static toString<T>(l: List<T>): string { return l.toString(); } static toString<T>(l: T[]): string { return l.toString(); }
static toJSON<T>(l: List<T>): string { return JSON.stringify(l); } static toJSON<T>(l: T[]): string { return JSON.stringify(l); }
static maximum<T>(list: List<T>, predicate: (T) => number): T { static maximum<T>(list: T[], predicate: (T) => number): T {
if (list.length == 0) { if (list.length == 0) {
return null; return null;
} }
@ -316,12 +309,12 @@ export function iterateListLike(obj: any, fn: Function) {
// Safari and Internet Explorer do not support the iterable parameter to the // Safari and Internet Explorer do not support the iterable parameter to the
// Set constructor. We work around that by manually adding the items. // Set constructor. We work around that by manually adding the items.
var createSetFromList: {(lst: List<any>): Set<any>} = (function() { var createSetFromList: {(lst: any[]): Set<any>} = (function() {
var test = new Set([1, 2, 3]); var test = new Set([1, 2, 3]);
if (test.size === 3) { if (test.size === 3) {
return function createSetFromList(lst: List<any>): Set<any> { return new Set(lst); }; return function createSetFromList(lst: any[]): Set<any> { return new Set(lst); };
} else { } else {
return function createSetAndPopulateFromList(lst: List<any>): Set<any> { return function createSetAndPopulateFromList(lst: any[]): Set<any> {
var res = new Set(lst); var res = new Set(lst);
if (res.size !== lst.length) { if (res.size !== lst.length) {
for (var i = 0; i < lst.length; i++) { for (var i = 0; i < lst.length; i++) {
@ -333,7 +326,7 @@ var createSetFromList: {(lst: List<any>): Set<any>} = (function() {
} }
})(); })();
export class SetWrapper { export class SetWrapper {
static createFromList<T>(lst: List<T>): Set<T> { return createSetFromList(lst); } static createFromList<T>(lst: T[]): Set<T> { return createSetFromList(lst); }
static has<T>(s: Set<T>, key: T): boolean { return s.has(key); } static has<T>(s: Set<T>, key: T): boolean { return s.has(key); }
static delete<K>(m: Set<K>, k: K) { m.delete(k); } static delete<K>(m: Set<K>, k: K) { m.delete(k); }
} }

View File

@ -159,7 +159,7 @@ export class StringWrapper {
static charCodeAt(s: string, index: number): number { return s.charCodeAt(index); } static charCodeAt(s: string, index: number): number { return s.charCodeAt(index); }
static split(s: string, regExp: RegExp): List<string> { return s.split(regExp); } static split(s: string, regExp: RegExp): string[] { return s.split(regExp); }
static equals(s: string, s2: string): boolean { return s === s2; } static equals(s: string, s2: string): boolean { return s === s2; }
@ -269,7 +269,7 @@ export class RegExpWrapper {
flags = flags.replace(/g/g, ''); flags = flags.replace(/g/g, '');
return new _global.RegExp(regExpStr, flags + 'g'); return new _global.RegExp(regExpStr, flags + 'g');
} }
static firstMatch(regExp: RegExp, input: string): List<string> { static firstMatch(regExp: RegExp, input: string): string[] {
// Reset multimatch regex state // Reset multimatch regex state
regExp.lastIndex = 0; regExp.lastIndex = 0;
return regExp.exec(input); return regExp.exec(input);

View File

@ -57,11 +57,11 @@ export interface ComponentDecorator extends TypeDecorator {
View(obj: { View(obj: {
templateUrl?: string, templateUrl?: string,
template?: string, template?: string,
directives?: List<Type | any | List<any>>, directives?: Array<Type | any | any[]>,
pipes?: List<Type | any | List<any>>, pipes?: Array<Type | any | any[]>,
renderer?: string, renderer?: string,
styles?: List<string>, styles?: string[],
styleUrls?: List<string>, styleUrls?: string[],
}): ViewDecorator; }): ViewDecorator;
} }
@ -77,11 +77,11 @@ export interface ViewDecorator extends TypeDecorator {
View(obj: { View(obj: {
templateUrl?: string, templateUrl?: string,
template?: string, template?: string,
directives?: List<Type | any | List<any>>, directives?: Array<Type | any | any[]>,
pipes?: List<Type | any | List<any>>, pipes?: Array<Type | any | any[]>,
renderer?: string, renderer?: string,
styles?: List<string>, styles?: string[],
styleUrls?: List<string>, styleUrls?: string[],
}): ViewDecorator; }): ViewDecorator;
} }
@ -127,14 +127,14 @@ export interface ViewDecorator extends TypeDecorator {
*/ */
export interface DirectiveFactory { export interface DirectiveFactory {
(obj: { (obj: {
selector?: string, properties?: List<string>, events?: List<string>, selector?: string, properties?: string[], events?: string[], host?: StringMap<string, string>,
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>, lifecycle?: LifecycleEvent[], bindings?: any[], exportAs?: string,
exportAs?: string, compileChildren?: boolean; compileChildren?: boolean;
}): DirectiveDecorator; }): DirectiveDecorator;
new (obj: { new (obj: {
selector?: string, properties?: List<string>, events?: List<string>, selector?: string, properties?: string[], events?: string[], host?: StringMap<string, string>,
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>, lifecycle?: LifecycleEvent[], bindings?: any[], exportAs?: string,
exportAs?: string, compileChildren?: boolean; compileChildren?: boolean;
}): DirectiveMetadata; }): DirectiveMetadata;
} }
@ -184,26 +184,26 @@ export interface DirectiveFactory {
export interface ComponentFactory { export interface ComponentFactory {
(obj: { (obj: {
selector?: string, selector?: string,
properties?: List<string>, properties?: string[],
events?: List<string>, events?: string[],
host?: StringMap<string, string>, host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>, lifecycle?: LifecycleEvent[],
bindings?: List<any>, bindings?: any[],
exportAs?: string, exportAs?: string,
compileChildren?: boolean, compileChildren?: boolean,
viewBindings?: List<any>, viewBindings?: any[],
changeDetection?: ChangeDetectionStrategy, changeDetection?: ChangeDetectionStrategy,
}): ComponentDecorator; }): ComponentDecorator;
new (obj: { new (obj: {
selector?: string, selector?: string,
properties?: List<string>, properties?: string[],
events?: List<string>, events?: string[],
host?: StringMap<string, string>, host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>, lifecycle?: LifecycleEvent[],
bindings?: List<any>, bindings?: any[],
exportAs?: string, exportAs?: string,
compileChildren?: boolean, compileChildren?: boolean,
viewBindings?: List<any>, viewBindings?: any[],
changeDetection?: ChangeDetectionStrategy, changeDetection?: ChangeDetectionStrategy,
}): ComponentMetadata; }): ComponentMetadata;
} }
@ -255,18 +255,18 @@ export interface ViewFactory {
(obj: { (obj: {
templateUrl?: string, templateUrl?: string,
template?: string, template?: string,
directives?: List<Type | any | List<any>>, directives?: Array<Type | any | any[]>,
encapsulation?: ViewEncapsulation, encapsulation?: ViewEncapsulation,
styles?: List<string>, styles?: string[],
styleUrls?: List<string>, styleUrls?: string[],
}): ViewDecorator; }): ViewDecorator;
new (obj: { new (obj: {
templateUrl?: string, templateUrl?: string,
template?: string, template?: string,
directives?: List<Type | any | List<any>>, directives?: Array<Type | any | any[]>,
encapsulation?: ViewEncapsulation, encapsulation?: ViewEncapsulation,
styles?: List<string>, styles?: string[],
styleUrls?: List<string>, styleUrls?: string[],
}): ViewMetadata; }): ViewMetadata;
} }

View File

@ -70,7 +70,7 @@ export class QueryMetadata extends DependencyMetadata {
get isVarBindingQuery(): boolean { return isString(this.selector); } get isVarBindingQuery(): boolean { return isString(this.selector); }
get varBindings(): List<string> { return StringWrapper.split(this.selector, new RegExp(",")); } get varBindings(): string[] { return StringWrapper.split(this.selector, new RegExp(",")); }
toString(): string { return `@Query(${stringify(this.selector)})`; } toString(): string { return `@Query(${stringify(this.selector)})`; }
} }

View File

@ -1,5 +1,4 @@
import {CONST, CONST_EXPR} from 'angular2/src/core/facade/lang'; import {CONST, CONST_EXPR} from 'angular2/src/core/facade/lang';
import {List} from 'angular2/src/core/facade/collection';
import {InjectableMetadata} from 'angular2/src/core/di/metadata'; import {InjectableMetadata} from 'angular2/src/core/di/metadata';
import {ChangeDetectionStrategy} from 'angular2/change_detection'; import {ChangeDetectionStrategy} from 'angular2/change_detection';
@ -482,7 +481,7 @@ export class DirectiveMetadata extends InjectableMetadata {
* ``` * ```
* *
*/ */
properties: List<string>; properties: string[];
/** /**
* Enumerates the set of emitted events. * Enumerates the set of emitted events.
@ -527,7 +526,7 @@ export class DirectiveMetadata extends InjectableMetadata {
* ``` * ```
* *
*/ */
events: List<string>; events: string[];
/** /**
* Specifiy the events, actions, properties and attributes related to the host element. * Specifiy the events, actions, properties and attributes related to the host element.
@ -636,7 +635,7 @@ export class DirectiveMetadata extends InjectableMetadata {
* *
* See {@link LifecycleEvent} for details. * See {@link LifecycleEvent} for details.
*/ */
lifecycle: List<LifecycleEvent>; lifecycle: LifecycleEvent[];
/** /**
* If set to false the compiler does not compile the children of this directive. * If set to false the compiler does not compile the children of this directive.
@ -674,7 +673,7 @@ export class DirectiveMetadata extends InjectableMetadata {
* } * }
* ``` * ```
*/ */
bindings: List<any>; bindings: any[];
/** /**
* Defines the name that can be used in the template to assign this directive to a variable. * Defines the name that can be used in the template to assign this directive to a variable.
@ -708,11 +707,11 @@ export class DirectiveMetadata extends InjectableMetadata {
compileChildren = true, compileChildren = true,
}: { }: {
selector?: string, selector?: string,
properties?: List<string>, properties?: string[],
events?: List<string>, events?: string[],
host?: StringMap<string, string>, host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>, lifecycle?: LifecycleEvent[],
bindings?: List<any>, bindings?: any[],
exportAs?: string, exportAs?: string,
compileChildren?: boolean, compileChildren?: boolean,
} = {}) { } = {}) {
@ -817,19 +816,19 @@ export class ComponentMetadata extends DirectiveMetadata {
* *
* ``` * ```
*/ */
viewBindings: List<any>; viewBindings: any[];
constructor({selector, properties, events, host, exportAs, lifecycle, bindings, viewBindings, constructor({selector, properties, events, host, exportAs, lifecycle, bindings, viewBindings,
changeDetection = ChangeDetectionStrategy.Default, compileChildren = true}: { changeDetection = ChangeDetectionStrategy.Default, compileChildren = true}: {
selector?: string, selector?: string,
properties?: List<string>, properties?: string[],
events?: List<string>, events?: string[],
host?: StringMap<string, string>, host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>, lifecycle?: LifecycleEvent[],
bindings?: List<any>, bindings?: any[],
exportAs?: string, exportAs?: string,
compileChildren?: boolean, compileChildren?: boolean,
viewBindings?: List<any>, viewBindings?: any[],
changeDetection?: ChangeDetectionStrategy, changeDetection?: ChangeDetectionStrategy,
} = {}) { } = {}) {
super({ super({

View File

@ -53,12 +53,12 @@ export class ViewMetadata {
/** /**
* Specifies stylesheet URLs for an angular component. * Specifies stylesheet URLs for an angular component.
*/ */
styleUrls: List<string>; styleUrls: string[];
/** /**
* Specifies an inline stylesheet for an angular component. * Specifies an inline stylesheet for an angular component.
*/ */
styles: List<string>; styles: string[];
/** /**
* Specifies a list of directives that can be used within a template. * Specifies a list of directives that can be used within a template.
@ -82,12 +82,12 @@ export class ViewMetadata {
* } * }
* ``` * ```
*/ */
// TODO(tbosch): use Type | Binding | List<any> when Dart supports union types, // TODO(tbosch): use Type | Binding | any[] when Dart supports union types,
// as otherwise we would need to import Binding type and Dart would warn // as otherwise we would need to import Binding type and Dart would warn
// for an unused import. // for an unused import.
directives: List<Type | any | List<any>>; directives: Array<Type | any | any[]>;
pipes: List<Type | any | List<any>>; pipes: Array<Type | any | any[]>;
/** /**
* Specify how the template and the styles should be encapsulated. * Specify how the template and the styles should be encapsulated.
@ -100,11 +100,11 @@ export class ViewMetadata {
constructor({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls}: { constructor({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls}: {
templateUrl?: string, templateUrl?: string,
template?: string, template?: string,
directives?: List<Type | any | List<any>>, directives?: Array<Type | any | any[]>,
pipes?: List<Type | any | List<any>>, pipes?: Array<Type | any | any[]>,
encapsulation?: ViewEncapsulation, encapsulation?: ViewEncapsulation,
styles?: List<string>, styles?: string[],
styleUrls?: List<string>, styleUrls?: string[],
} = {}) { } = {}) {
this.templateUrl = templateUrl; this.templateUrl = templateUrl;
this.template = template; this.template = template;

View File

@ -93,7 +93,7 @@ export class DatePipe implements PipeTransform {
}; };
transform(value: any, args: List<any>): string { transform(value: any, args: any[]): string {
if (isBlank(value)) return null; if (isBlank(value)) return null;
if (!this.supports(value)) { if (!this.supports(value)) {

View File

@ -32,5 +32,5 @@ import {Pipe} from '../metadata';
@Pipe({name: 'json'}) @Pipe({name: 'json'})
@Injectable() @Injectable()
export class JsonPipe implements PipeTransform { export class JsonPipe implements PipeTransform {
transform(value: any, args: List<any> = null): string { return Json.stringify(value); } transform(value: any, args: any[] = null): string { return Json.stringify(value); }
} }

View File

@ -16,7 +16,7 @@ import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from '../metadata'; import {Pipe} from '../metadata';
/** /**
* Creates a new List or String containing only a prefix/suffix of the * Creates a new Array or String containing only a prefix/suffix of the
* elements. * elements.
* *
* The number of elements to return is specified by the `limitTo` parameter. * The number of elements to return is specified by the `limitTo` parameter.
@ -25,19 +25,19 @@ import {Pipe} from '../metadata';
* *
* expression | limitTo:number * expression | limitTo:number
* *
* Where the input expression is a [List] or [String], and `limitTo` is: * Where the input expression is a [Array] or [String], and `limitTo` is:
* *
* - **a positive integer**: return _number_ items from the beginning of the list or string * - **a positive integer**: return _number_ items from the beginning of the list or string
* expression. * expression.
* - **a negative integer**: return _number_ items from the end of the list or string expression. * - **a negative integer**: return _number_ items from the end of the list or string expression.
* - **`|limitTo|` greater than the size of the expression**: return the entire expression. * - **`|limitTo|` greater than the size of the expression**: return the entire expression.
* *
* When operating on a [List], the returned list is always a copy even when all * When operating on a [Array], the returned list is always a copy even when all
* the elements are being returned. * the elements are being returned.
* *
* # Examples * # Examples
* *
* ## List Example * ## Array Example
* *
* Assuming `var collection = ['a', 'b', 'c']`, this `ng-for` directive: * Assuming `var collection = ['a', 'b', 'c']`, this `ng-for` directive:
* *
@ -59,7 +59,7 @@ import {Pipe} from '../metadata';
export class LimitToPipe implements PipeTransform { export class LimitToPipe implements PipeTransform {
supports(obj: any): boolean { return isString(obj) || isArray(obj); } supports(obj: any): boolean { return isString(obj) || isArray(obj); }
transform(value: any, args: List<any> = null): any { transform(value: any, args: any[] = null): any {
if (isBlank(args) || args.length == 0) { if (isBlank(args) || args.length == 0) {
throw new BaseException('limitTo pipe requires one argument'); throw new BaseException('limitTo pipe requires one argument');
} }

View File

@ -31,7 +31,7 @@ import {Pipe} from '../metadata';
@Pipe({name: 'lowercase'}) @Pipe({name: 'lowercase'})
@Injectable() @Injectable()
export class LowerCasePipe implements PipeTransform { export class LowerCasePipe implements PipeTransform {
transform(value: string, args: List<any> = null): string { transform(value: string, args: any[] = null): string {
if (isBlank(value)) return value; if (isBlank(value)) return value;
if (!isString(value)) { if (!isString(value)) {
throw new InvalidPipeArgumentException(LowerCasePipe, value); throw new InvalidPipeArgumentException(LowerCasePipe, value);

View File

@ -30,7 +30,7 @@ import {Pipe} from '../metadata';
@Pipe({name: 'uppercase'}) @Pipe({name: 'uppercase'})
@Injectable() @Injectable()
export class UpperCasePipe implements PipeTransform { export class UpperCasePipe implements PipeTransform {
transform(value: string, args: List<any> = null): string { transform(value: string, args: any[] = null): string {
if (isBlank(value)) return value; if (isBlank(value)) return value;
if (!isString(value)) { if (!isString(value)) {
throw new InvalidPipeArgumentException(UpperCasePipe, value); throw new InvalidPipeArgumentException(UpperCasePipe, value);

View File

@ -1,13 +1,12 @@
import {Type} from 'angular2/src/core/facade/lang'; import {Type} from 'angular2/src/core/facade/lang';
import {GetterFn, SetterFn, MethodFn} from './types'; import {GetterFn, SetterFn, MethodFn} from './types';
import {List} from 'angular2/src/core/facade/collection';
export interface PlatformReflectionCapabilities { export interface PlatformReflectionCapabilities {
isReflectionEnabled(): boolean; isReflectionEnabled(): boolean;
factory(type: Type): Function; factory(type: Type): Function;
interfaces(type: Type): List<any>; interfaces(type: Type): any[];
parameters(type: Type): List<List<any>>; parameters(type: Type): any[][];
annotations(type: Type): List<any>; annotations(type: Type): any[];
getter(name: string): GetterFn; getter(name: string): GetterFn;
setter(name: string): SetterFn; setter(name: string): SetterFn;
method(name: string): MethodFn; method(name: string): MethodFn;

View File

@ -1,5 +1,5 @@
import {Type, isPresent} from 'angular2/src/core/facade/lang'; import {Type, isPresent} from 'angular2/src/core/facade/lang';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {Reflector} from './reflector'; import {Reflector} from './reflector';
export {Reflector, ReflectionInfo} from './reflector'; export {Reflector, ReflectionInfo} from './reflector';
import {ReflectionCapabilities} from './reflection_capabilities'; import {ReflectionCapabilities} from './reflection_capabilities';

View File

@ -6,7 +6,7 @@ import {
stringify, stringify,
BaseException BaseException
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {GetterFn, SetterFn, MethodFn} from './types'; import {GetterFn, SetterFn, MethodFn} from './types';
import {PlatformReflectionCapabilities} from 'platform_reflection_capabilities'; import {PlatformReflectionCapabilities} from 'platform_reflection_capabilities';
@ -82,7 +82,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
`Cannot create a factory for '${stringify(t)}' because its constructor has more than 20 arguments`); `Cannot create a factory for '${stringify(t)}' because its constructor has more than 20 arguments`);
} }
_zipTypesAndAnnotaions(paramTypes, paramAnnotations): List<List<any>> { _zipTypesAndAnnotaions(paramTypes, paramAnnotations): any[][] {
var result; var result;
if (typeof paramTypes === 'undefined') { if (typeof paramTypes === 'undefined') {
@ -109,7 +109,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return result; return result;
} }
parameters(typeOfFunc: Type): List<List<any>> { parameters(typeOfFunc: Type): any[][] {
// Prefer the direct API. // Prefer the direct API.
if (isPresent((<any>typeOfFunc).parameters)) { if (isPresent((<any>typeOfFunc).parameters)) {
return (<any>typeOfFunc).parameters; return (<any>typeOfFunc).parameters;
@ -124,7 +124,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return ListWrapper.createFixedSize((<any>typeOfFunc).length); return ListWrapper.createFixedSize((<any>typeOfFunc).length);
} }
annotations(typeOfFunc: Type): List<any> { annotations(typeOfFunc: Type): any[] {
// Prefer the direct API. // Prefer the direct API.
if (isPresent((<any>typeOfFunc).annotations)) { if (isPresent((<any>typeOfFunc).annotations)) {
var annotations = (<any>typeOfFunc).annotations; var annotations = (<any>typeOfFunc).annotations;
@ -140,7 +140,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return []; return [];
} }
interfaces(type: Type): List<any> { interfaces(type: Type): any[] {
throw new BaseException("JavaScript does not support interfaces"); throw new BaseException("JavaScript does not support interfaces");
} }

View File

@ -1,6 +1,5 @@
import {Type, isPresent, stringify, BaseException} from 'angular2/src/core/facade/lang'; import {Type, isPresent, stringify, BaseException} from 'angular2/src/core/facade/lang';
import { import {
List,
ListWrapper, ListWrapper,
Map, Map,
MapWrapper, MapWrapper,
@ -16,12 +15,11 @@ export {PlatformReflectionCapabilities} from './platform_reflection_capabilities
export class ReflectionInfo { export class ReflectionInfo {
_factory: Function; _factory: Function;
_annotations: List<any>; _annotations: any[];
_parameters: List<List<any>>; _parameters: any[][];
_interfaces: List<any>; _interfaces: any[];
constructor(annotations?: List<any>, parameters?: List<List<any>>, factory?: Function, constructor(annotations?: any[], parameters?: any[][], factory?: Function, interfaces?: any[]) {
interfaces?: List<any>) {
this._annotations = annotations; this._annotations = annotations;
this._parameters = parameters; this._parameters = parameters;
this._factory = factory; this._factory = factory;
@ -59,7 +57,7 @@ export class Reflector {
* {@link #trackUsage} was called. This list could later be audited as * {@link #trackUsage} was called. This list could later be audited as
* potential dead code. * potential dead code.
*/ */
listUnusedKeys(): List<any> { listUnusedKeys(): any[] {
if (this._usedKeys == null) { if (this._usedKeys == null) {
throw new BaseException('Usage tracking is disabled'); throw new BaseException('Usage tracking is disabled');
} }
@ -96,7 +94,7 @@ export class Reflector {
} }
} }
parameters(typeOrFunc: /*Type*/ any): List<any> { parameters(typeOrFunc: /*Type*/ any): any[] {
if (this._injectableInfo.has(typeOrFunc)) { if (this._injectableInfo.has(typeOrFunc)) {
var res = this._getReflectionInfo(typeOrFunc)._parameters; var res = this._getReflectionInfo(typeOrFunc)._parameters;
return isPresent(res) ? res : []; return isPresent(res) ? res : [];
@ -105,7 +103,7 @@ export class Reflector {
} }
} }
annotations(typeOrFunc: /*Type*/ any): List<any> { annotations(typeOrFunc: /*Type*/ any): any[] {
if (this._injectableInfo.has(typeOrFunc)) { if (this._injectableInfo.has(typeOrFunc)) {
var res = this._getReflectionInfo(typeOrFunc)._annotations; var res = this._getReflectionInfo(typeOrFunc)._annotations;
return isPresent(res) ? res : []; return isPresent(res) ? res : [];
@ -114,7 +112,7 @@ export class Reflector {
} }
} }
interfaces(type: Type): List<any> { interfaces(type: Type): any[] {
if (this._injectableInfo.has(type)) { if (this._injectableInfo.has(type)) {
var res = this._getReflectionInfo(type)._interfaces; var res = this._getReflectionInfo(type)._interfaces;
return isPresent(res) ? res : []; return isPresent(res) ? res : [];

View File

@ -1,6 +1,5 @@
import {Type} from 'angular2/src/core/facade/lang'; import {Type} from 'angular2/src/core/facade/lang';
import {List} from 'angular2/src/core/facade/collection';
export type SetterFn = (obj: any, value: any) => void; export type SetterFn = (obj: any, value: any) => void;
export type GetterFn = (obj: any) => any; export type GetterFn = (obj: any) => any;
export type MethodFn = (obj: any, args: List<any>) => any; export type MethodFn = (obj: any, args: any[]) => any;

View File

@ -1,12 +1,6 @@
import {isPresent, isBlank, RegExpWrapper} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, RegExpWrapper} from 'angular2/src/core/facade/lang';
import {Promise} from 'angular2/src/core/facade/async'; import {Promise} from 'angular2/src/core/facade/async';
import { import {Map, MapWrapper, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
List,
Map,
MapWrapper,
StringMap,
StringMapWrapper
} from 'angular2/src/core/facade/collection';
import { import {
ASTWithSource, ASTWithSource,
ChangeDetectionStrategy ChangeDetectionStrategy
@ -49,14 +43,14 @@ export class RenderElementBinder {
index: number; index: number;
parentIndex: number; parentIndex: number;
distanceToParent: number; distanceToParent: number;
directives: List<DirectiveBinder>; directives: DirectiveBinder[];
nestedProtoView: ProtoViewDto; nestedProtoView: ProtoViewDto;
propertyBindings: List<ElementPropertyBinding>; propertyBindings: ElementPropertyBinding[];
variableBindings: Map<string, string>; variableBindings: Map<string, string>;
// Note: this contains a preprocessed AST // Note: this contains a preprocessed AST
// that replaced the values that should be extracted from the element // that replaced the values that should be extracted from the element
// with a local name // with a local name
eventBindings: List<EventBinding>; eventBindings: EventBinding[];
readAttributes: Map<string, string>; readAttributes: Map<string, string>;
constructor({index, parentIndex, distanceToParent, directives, nestedProtoView, propertyBindings, constructor({index, parentIndex, distanceToParent, directives, nestedProtoView, propertyBindings,
@ -64,11 +58,11 @@ export class RenderElementBinder {
index?: number, index?: number,
parentIndex?: number, parentIndex?: number,
distanceToParent?: number, distanceToParent?: number,
directives?: List<DirectiveBinder>, directives?: DirectiveBinder[],
nestedProtoView?: ProtoViewDto, nestedProtoView?: ProtoViewDto,
propertyBindings?: List<ElementPropertyBinding>, propertyBindings?: ElementPropertyBinding[],
variableBindings?: Map<string, string>, variableBindings?: Map<string, string>,
eventBindings?: List<EventBinding>, eventBindings?: EventBinding[],
readAttributes?: Map<string, string> readAttributes?: Map<string, string>
} = {}) { } = {}) {
this.index = index; this.index = index;
@ -90,13 +84,13 @@ export class DirectiveBinder {
// Note: this contains a preprocessed AST // Note: this contains a preprocessed AST
// that replaced the values that should be extracted from the element // that replaced the values that should be extracted from the element
// with a local name // with a local name
eventBindings: List<EventBinding>; eventBindings: EventBinding[];
hostPropertyBindings: List<ElementPropertyBinding>; hostPropertyBindings: ElementPropertyBinding[];
constructor({directiveIndex, propertyBindings, eventBindings, hostPropertyBindings}: { constructor({directiveIndex, propertyBindings, eventBindings, hostPropertyBindings}: {
directiveIndex?: number, directiveIndex?: number,
propertyBindings?: Map<string, ASTWithSource>, propertyBindings?: Map<string, ASTWithSource>,
eventBindings?: List<EventBinding>, eventBindings?: EventBinding[],
hostPropertyBindings?: List<ElementPropertyBinding> hostPropertyBindings?: ElementPropertyBinding[]
}) { }) {
this.directiveIndex = directiveIndex; this.directiveIndex = directiveIndex;
this.propertyBindings = propertyBindings; this.propertyBindings = propertyBindings;
@ -119,19 +113,19 @@ export enum ViewType {
export class ProtoViewDto { export class ProtoViewDto {
render: RenderProtoViewRef; render: RenderProtoViewRef;
elementBinders: List<RenderElementBinder>; elementBinders: RenderElementBinder[];
variableBindings: Map<string, string>; variableBindings: Map<string, string>;
type: ViewType; type: ViewType;
textBindings: List<ASTWithSource>; textBindings: ASTWithSource[];
transitiveNgContentCount: number; transitiveNgContentCount: number;
constructor({render, elementBinders, variableBindings, type, textBindings, constructor({render, elementBinders, variableBindings, type, textBindings,
transitiveNgContentCount}: { transitiveNgContentCount}: {
render?: RenderProtoViewRef, render?: RenderProtoViewRef,
elementBinders?: List<RenderElementBinder>, elementBinders?: RenderElementBinder[],
variableBindings?: Map<string, string>, variableBindings?: Map<string, string>,
type?: ViewType, type?: ViewType,
textBindings?: List<ASTWithSource>, textBindings?: ASTWithSource[],
transitiveNgContentCount?: number transitiveNgContentCount?: number
}) { }) {
this.render = render; this.render = render;
@ -149,9 +143,9 @@ export class RenderDirectiveMetadata {
id: any; id: any;
selector: string; selector: string;
compileChildren: boolean; compileChildren: boolean;
events: List<string>; events: string[];
properties: List<string>; properties: string[];
readAttributes: List<string>; readAttributes: string[];
type: number; type: number;
callOnDestroy: boolean; callOnDestroy: boolean;
callOnChanges: boolean; callOnChanges: boolean;
@ -177,12 +171,12 @@ export class RenderDirectiveMetadata {
id?: string, id?: string,
selector?: string, selector?: string,
compileChildren?: boolean, compileChildren?: boolean,
events?: List<string>, events?: string[],
hostListeners?: Map<string, string>, hostListeners?: Map<string, string>,
hostProperties?: Map<string, string>, hostProperties?: Map<string, string>,
hostAttributes?: Map<string, string>, hostAttributes?: Map<string, string>,
properties?: List<string>, properties?: string[],
readAttributes?: List<string>, readAttributes?: string[],
type?: number, type?: number,
callOnDestroy?: boolean, callOnDestroy?: boolean,
callOnChanges?: boolean, callOnChanges?: boolean,
@ -224,10 +218,10 @@ export class RenderDirectiveMetadata {
id?: string, id?: string,
selector?: string, selector?: string,
compileChildren?: boolean, compileChildren?: boolean,
events?: List<string>, events?: string[],
host?: Map<string, string>, host?: Map<string, string>,
properties?: List<string>, properties?: string[],
readAttributes?: List<string>, readAttributes?: string[],
type?: number, type?: number,
callOnDestroy?: boolean, callOnDestroy?: boolean,
callOnChanges?: boolean, callOnChanges?: boolean,
@ -314,9 +308,9 @@ export class ViewDefinition {
componentId: string; componentId: string;
templateAbsUrl: string; templateAbsUrl: string;
template: string; template: string;
directives: List<RenderDirectiveMetadata>; directives: RenderDirectiveMetadata[];
styleAbsUrls: List<string>; styleAbsUrls: string[];
styles: List<string>; styles: string[];
encapsulation: ViewEncapsulation; encapsulation: ViewEncapsulation;
constructor({componentId, templateAbsUrl, template, styleAbsUrls, styles, directives, constructor({componentId, templateAbsUrl, template, styleAbsUrls, styles, directives,
@ -324,9 +318,9 @@ export class ViewDefinition {
componentId?: string, componentId?: string,
templateAbsUrl?: string, templateAbsUrl?: string,
template?: string, template?: string,
styleAbsUrls?: List<string>, styleAbsUrls?: string[],
styles?: List<string>, styles?: string[],
directives?: List<RenderDirectiveMetadata>, directives?: RenderDirectiveMetadata[],
encapsulation?: ViewEncapsulation encapsulation?: ViewEncapsulation
} = {}) { } = {}) {
this.componentId = componentId; this.componentId = componentId;
@ -381,11 +375,11 @@ export class RenderCompiler {
* should be merged. * should be merged.
* If the array contains other arrays, they will be merged before processing the parent array. * If the array contains other arrays, they will be merged before processing the parent array.
* The array must contain an entry for every component and embedded ProtoView of the first entry. * The array must contain an entry for every component and embedded ProtoView of the first entry.
* @param protoViewRefs List of ProtoViewRefs or nested * @param protoViewRefs Array of ProtoViewRefs or nested
* @return the merge result * @return the merge result
*/ */
mergeProtoViewsRecursively( mergeProtoViewsRecursively(
protoViewRefs: List<RenderProtoViewRef | List<any>>): Promise<RenderProtoViewMergeMapping> { protoViewRefs: Array<RenderProtoViewRef | any[]>): Promise<RenderProtoViewMergeMapping> {
return null; return null;
} }
} }
@ -500,7 +494,7 @@ export class Renderer {
/** /**
* Calls a method on an element. * Calls a method on an element.
*/ */
invokeElementMethod(location: RenderElementRef, methodName: string, args: List<any>) {} invokeElementMethod(location: RenderElementRef, methodName: string, args: any[]) {}
/** /**
* Sets the value of a text node. * Sets the value of a text node.

View File

@ -1,5 +1,4 @@
import {isBlank} from 'angular2/src/core/facade/lang'; import {isBlank} from 'angular2/src/core/facade/lang';
import {List, ListWrapper} from 'angular2/src/core/facade/collection';
import {CompileElement} from './compile_element'; import {CompileElement} from './compile_element';
import {CompileStep} from './compile_step'; import {CompileStep} from './compile_step';
@ -14,7 +13,7 @@ export class CompileControl {
_additionalChildren: CompileElement[] = null; _additionalChildren: CompileElement[] = null;
_ignoreCurrentElement: boolean; _ignoreCurrentElement: boolean;
constructor(public _steps: List<CompileStep>) {} constructor(public _steps: CompileStep[]) {}
// only public so that it can be used by compile_pipeline // only public so that it can be used by compile_pipeline
internalProcess(results: any[], startStepIndex: number, parent: CompileElement, internalProcess(results: any[], startStepIndex: number, parent: CompileElement,

View File

@ -1,4 +1,4 @@
import {List, Map, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection'; import {Map, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import { import {
isBlank, isBlank,
@ -17,7 +17,7 @@ import {ProtoViewBuilder, ElementBinderBuilder} from '../view/proto_view_builder
*/ */
export class CompileElement { export class CompileElement {
_attrs: Map<string, string> = null; _attrs: Map<string, string> = null;
_classList: List<string> = null; _classList: string[] = null;
isViewRoot: boolean = false; isViewRoot: boolean = false;
// inherited down to children if they don't have an own protoView // inherited down to children if they don't have an own protoView
inheritedProtoView: ProtoViewBuilder = null; inheritedProtoView: ProtoViewBuilder = null;
@ -63,7 +63,7 @@ export class CompileElement {
return this._attrs; return this._attrs;
} }
classList(): List<string> { classList(): string[] {
if (isBlank(this._classList)) { if (isBlank(this._classList)) {
this._classList = []; this._classList = [];
var elClassList = DOM.classList(this.element); var elClassList = DOM.classList(this.element);

View File

@ -1,5 +1,4 @@
import {isPresent, isBlank} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
import {List, ListWrapper} from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {CompileElement} from './compile_element'; import {CompileElement} from './compile_element';
import {CompileControl} from './compile_control'; import {CompileControl} from './compile_control';
@ -13,7 +12,7 @@ import {ProtoViewDto, ViewType, ViewDefinition} from '../../api';
*/ */
export class CompilePipeline { export class CompilePipeline {
_control: CompileControl; _control: CompileControl;
constructor(public steps: List<CompileStep>) { this._control = new CompileControl(steps); } constructor(public steps: CompileStep[]) { this._control = new CompileControl(steps); }
processStyles(styles: string[]): string[] { processStyles(styles: string[]): string[] {
return styles.map(style => { return styles.map(style => {

View File

@ -1,4 +1,3 @@
import {List} from 'angular2/src/core/facade/collection';
import {Parser} from 'angular2/src/core/change_detection/change_detection'; import {Parser} from 'angular2/src/core/change_detection/change_detection';
import {ViewDefinition} from '../../api'; import {ViewDefinition} from '../../api';
import {CompileStep} from './compile_step'; import {CompileStep} from './compile_step';
@ -9,14 +8,14 @@ import {ViewSplitter} from './view_splitter';
import {StyleEncapsulator} from './style_encapsulator'; import {StyleEncapsulator} from './style_encapsulator';
export class CompileStepFactory { export class CompileStepFactory {
createSteps(view: ViewDefinition): List<CompileStep> { return null; } createSteps(view: ViewDefinition): CompileStep[] { return null; }
} }
export class DefaultStepFactory extends CompileStepFactory { export class DefaultStepFactory extends CompileStepFactory {
private _componentUIDsCache: Map<string, string> = new Map(); private _componentUIDsCache: Map<string, string> = new Map();
constructor(private _parser: Parser, private _appId: string) { super(); } constructor(private _parser: Parser, private _appId: string) { super(); }
createSteps(view: ViewDefinition): List<CompileStep> { createSteps(view: ViewDefinition): CompileStep[] {
return [ return [
new ViewSplitter(this._parser), new ViewSplitter(this._parser),
new PropertyBindingParser(this._parser), new PropertyBindingParser(this._parser),

View File

@ -68,7 +68,7 @@ export class DomCompiler extends RenderCompiler {
} }
mergeProtoViewsRecursively( mergeProtoViewsRecursively(
protoViewRefs: List<RenderProtoViewRef | List<any>>): Promise<RenderProtoViewMergeMapping> { protoViewRefs: Array<RenderProtoViewRef | any[]>): Promise<RenderProtoViewMergeMapping> {
return PromiseWrapper.resolve( return PromiseWrapper.resolve(
pvm.mergeProtoViewsRecursively(this._templateCloner, protoViewRefs)); pvm.mergeProtoViewsRecursively(this._templateCloner, protoViewRefs));
} }

View File

@ -1,5 +1,5 @@
import {isPresent, isBlank, BaseException, StringWrapper} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, BaseException, StringWrapper} from 'angular2/src/core/facade/lang';
import {List, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Parser} from 'angular2/src/core/change_detection/change_detection'; import {Parser} from 'angular2/src/core/change_detection/change_detection';
@ -21,7 +21,7 @@ import {DirectiveBuilder, ElementBinderBuilder} from '../view/proto_view_builder
export class DirectiveParser implements CompileStep { export class DirectiveParser implements CompileStep {
_selectorMatcher: SelectorMatcher = new SelectorMatcher(); _selectorMatcher: SelectorMatcher = new SelectorMatcher();
constructor(public _parser: Parser, public _directives: List<RenderDirectiveMetadata>) { constructor(public _parser: Parser, public _directives: RenderDirectiveMetadata[]) {
for (var i = 0; i < _directives.length; i++) { for (var i = 0; i < _directives.length; i++) {
var directive = _directives[i]; var directive = _directives[i];
var selector = CssSelector.parse(directive.selector); var selector = CssSelector.parse(directive.selector);
@ -114,7 +114,7 @@ export class DirectiveParser implements CompileStep {
let dirProperty: string; let dirProperty: string;
// Name of the property on the element // Name of the property on the element
let elProp: string; let elProp: string;
let pipes: List<string>; let pipes: string[];
let assignIndex: number = bindConfig.indexOf(':'); let assignIndex: number = bindConfig.indexOf(':');
if (assignIndex > -1) { if (assignIndex > -1) {

View File

@ -1,4 +1,4 @@
import {List, Map, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection'; import {Map, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
import { import {
isPresent, isPresent,
isBlank, isBlank,
@ -322,7 +322,7 @@ export class SelectorMatcher {
var selectables = map.get(name); var selectables = map.get(name);
var starSelectables = map.get("*"); var starSelectables = map.get("*");
if (isPresent(starSelectables)) { if (isPresent(starSelectables)) {
selectables = ListWrapper.concat(selectables, starSelectables); selectables = selectables.concat(starSelectables);
} }
if (isBlank(selectables)) { if (isBlank(selectables)) {
return false; return false;

View File

@ -1,5 +1,5 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import { import {
StringWrapper, StringWrapper,
RegExp, RegExp,

View File

@ -42,8 +42,7 @@ export class StyleInliner {
return this._inlineImports(cssText, baseUrl, []); return this._inlineImports(cssText, baseUrl, []);
} }
_inlineImports(cssText: string, baseUrl: string, inlinedUrls: List<string>): Promise<string>| _inlineImports(cssText: string, baseUrl: string, inlinedUrls: string[]): Promise<string>| string {
string {
var partIndex = 0; var partIndex = 0;
var parts = StringWrapper.split(cssText, _importRe); var parts = StringWrapper.split(cssText, _importRe);

View File

@ -7,7 +7,7 @@ import {
isPromise, isPromise,
StringWrapper StringWrapper
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {Map, MapWrapper, ListWrapper, List} from 'angular2/src/core/facade/collection'; import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async'; import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {ViewDefinition} from '../../api'; import {ViewDefinition} from '../../api';
@ -35,7 +35,7 @@ export class ViewLoader {
load(viewDef: ViewDefinition): Promise<TemplateAndStyles> { load(viewDef: ViewDefinition): Promise<TemplateAndStyles> {
var r = wtfStartTimeRange('ViewLoader#load()', stringify(viewDef.componentId)); var r = wtfStartTimeRange('ViewLoader#load()', stringify(viewDef.componentId));
let tplAndStyles: List<Promise<TemplateAndStyles>| Promise<string>| string> = let tplAndStyles: Array<Promise<TemplateAndStyles>| Promise<string>| string> =
[this._loadHtml(viewDef.template, viewDef.templateAbsUrl, viewDef.componentId)]; [this._loadHtml(viewDef.template, viewDef.templateAbsUrl, viewDef.componentId)];
if (isPresent(viewDef.styles)) { if (isPresent(viewDef.styles)) {
viewDef.styles.forEach((cssText: string) => { viewDef.styles.forEach((cssText: string) => {
@ -54,7 +54,7 @@ export class ViewLoader {
// Inline the styles from the @View annotation // Inline the styles from the @View annotation
return PromiseWrapper.all(tplAndStyles) return PromiseWrapper.all(tplAndStyles)
.then((res: List<TemplateAndStyles | string>) => { .then((res: Array<TemplateAndStyles | string>) => {
let loadedTplAndStyles = <TemplateAndStyles>res[0]; let loadedTplAndStyles = <TemplateAndStyles>res[0];
let styles = <string[]>ListWrapper.slice(res, 1); let styles = <string[]>ListWrapper.slice(res, 1);

View File

@ -6,13 +6,6 @@ import {
RegExpWrapper, RegExpWrapper,
CONST_EXPR CONST_EXPR
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import {
ListWrapper,
MapWrapper,
Map,
StringMapWrapper,
List
} from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
@ -96,9 +89,7 @@ export class DomRenderer extends Renderer {
.boundElements[location.renderBoundElementIndex]; .boundElements[location.renderBoundElementIndex];
} }
getRootNodes(fragment: RenderFragmentRef): List<Node> { getRootNodes(fragment: RenderFragmentRef): Node[] { return resolveInternalDomFragment(fragment); }
return resolveInternalDomFragment(fragment);
}
attachFragmentAfterFragment(previousFragmentRef: RenderFragmentRef, attachFragmentAfterFragment(previousFragmentRef: RenderFragmentRef,
fragmentRef: RenderFragmentRef) { fragmentRef: RenderFragmentRef) {
@ -194,7 +185,7 @@ export class DomRenderer extends Renderer {
view.setElementStyle(location.renderBoundElementIndex, styleName, styleValue); view.setElementStyle(location.renderBoundElementIndex, styleName, styleValue);
} }
invokeElementMethod(location: RenderElementRef, methodName: string, args: List<any>): void { invokeElementMethod(location: RenderElementRef, methodName: string, args: any[]): void {
if (isBlank(location.renderBoundElementIndex)) { if (isBlank(location.renderBoundElementIndex)) {
return; return;
} }

View File

@ -1,12 +1,11 @@
import {isBlank, BaseException, isPresent, StringWrapper} from 'angular2/src/core/facade/lang'; import {isBlank, BaseException, isPresent, StringWrapper} from 'angular2/src/core/facade/lang';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {List, ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {NgZone} from 'angular2/src/core/zone/ng_zone';
var BUBBLE_SYMBOL = '^'; var BUBBLE_SYMBOL = '^';
export class EventManager { export class EventManager {
constructor(public _plugins: List<EventManagerPlugin>, public _zone: NgZone) { constructor(public _plugins: EventManagerPlugin[], public _zone: NgZone) {
for (var i = 0; i < _plugins.length; i++) { for (var i = 0; i < _plugins.length; i++) {
_plugins[i].manager = this; _plugins[i].manager = this;
} }

View File

@ -1,22 +1,21 @@
import {AST} from 'angular2/src/core/change_detection/change_detection'; import {AST} from 'angular2/src/core/change_detection/change_detection';
import {List, ListWrapper} from 'angular2/src/core/facade/collection';
import {isPresent} from 'angular2/src/core/facade/lang'; import {isPresent} from 'angular2/src/core/facade/lang';
export class DomElementBinder { export class DomElementBinder {
textNodeIndices: List<number>; textNodeIndices: number[];
hasNestedProtoView: boolean; hasNestedProtoView: boolean;
eventLocals: AST; eventLocals: AST;
localEvents: List<Event>; localEvents: Event[];
globalEvents: List<Event>; globalEvents: Event[];
hasNativeShadowRoot: boolean; hasNativeShadowRoot: boolean;
constructor({textNodeIndices, hasNestedProtoView, eventLocals, localEvents, globalEvents, constructor({textNodeIndices, hasNestedProtoView, eventLocals, localEvents, globalEvents,
hasNativeShadowRoot}: { hasNativeShadowRoot}: {
textNodeIndices?: List<number>, textNodeIndices?: number[],
hasNestedProtoView?: boolean, hasNestedProtoView?: boolean,
eventLocals?: AST, eventLocals?: AST,
localEvents?: List<Event>, localEvents?: Event[],
globalEvents?: List<Event>, globalEvents?: Event[],
hasNativeShadowRoot?: boolean hasNativeShadowRoot?: boolean
} = {}) { } = {}) {
this.textNodeIndices = textNodeIndices; this.textNodeIndices = textNodeIndices;

View File

@ -1,4 +1,4 @@
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {DomElementBinder} from './element_binder'; import {DomElementBinder} from './element_binder';
import {RenderProtoViewRef, ViewType, ViewEncapsulation} from '../../api'; import {RenderProtoViewRef, ViewType, ViewEncapsulation} from '../../api';
@ -18,7 +18,7 @@ export class DomProtoViewRef extends RenderProtoViewRef {
export class DomProtoView { export class DomProtoView {
static create(templateCloner: TemplateCloner, type: ViewType, rootElement: Element, static create(templateCloner: TemplateCloner, type: ViewType, rootElement: Element,
viewEncapsulation: ViewEncapsulation, fragmentsRootNodeCount: number[], viewEncapsulation: ViewEncapsulation, fragmentsRootNodeCount: number[],
rootTextNodeIndices: number[], elementBinders: List<DomElementBinder>, rootTextNodeIndices: number[], elementBinders: DomElementBinder[],
hostAttributes: Map<string, string>): DomProtoView { hostAttributes: Map<string, string>): DomProtoView {
var boundTextNodeCount = rootTextNodeIndices.length; var boundTextNodeCount = rootTextNodeIndices.length;
for (var i = 0; i < elementBinders.length; i++) { for (var i = 0; i < elementBinders.length; i++) {
@ -33,8 +33,7 @@ export class DomProtoView {
} }
// Note: fragments are separated by a comment node that is not counted in fragmentsRootNodeCount! // Note: fragments are separated by a comment node that is not counted in fragmentsRootNodeCount!
constructor(public type: ViewType, public cloneableTemplate: Element | string, constructor(public type: ViewType, public cloneableTemplate: Element | string,
public encapsulation: ViewEncapsulation, public encapsulation: ViewEncapsulation, public elementBinders: DomElementBinder[],
public elementBinders: List<DomElementBinder>,
public hostAttributes: Map<string, string>, public rootTextNodeIndices: number[], public hostAttributes: Map<string, string>, public rootTextNodeIndices: number[],
public boundTextNodeCount: number, public fragmentsRootNodeCount: number[], public boundTextNodeCount: number, public fragmentsRootNodeCount: number[],
public isSingleElementFragment: boolean) {} public isSingleElementFragment: boolean) {}

View File

@ -4,7 +4,6 @@ import {
MapWrapper, MapWrapper,
Set, Set,
SetWrapper, SetWrapper,
List,
StringMapWrapper StringMapWrapper
} from 'angular2/src/core/facade/collection'; } from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
@ -39,7 +38,7 @@ import {EVENT_TARGET_SEPARATOR} from "../../event_config";
export class ProtoViewBuilder { export class ProtoViewBuilder {
variableBindings: Map<string, string> = new Map(); variableBindings: Map<string, string> = new Map();
elements: List<ElementBinderBuilder> = []; elements: ElementBinderBuilder[] = [];
rootTextBindings: Map<Node, ASTWithSource> = new Map(); rootTextBindings: Map<Node, ASTWithSource> = new Map();
ngContentCount: number = 0; ngContentCount: number = 0;
hostAttributes: Map<string, string> = new Map(); hostAttributes: Map<string, string> = new Map();
@ -153,11 +152,11 @@ export class ProtoViewBuilder {
export class ElementBinderBuilder { export class ElementBinderBuilder {
parent: ElementBinderBuilder = null; parent: ElementBinderBuilder = null;
distanceToParent: number = 0; distanceToParent: number = 0;
directives: List<DirectiveBuilder> = []; directives: DirectiveBuilder[] = [];
nestedProtoView: ProtoViewBuilder = null; nestedProtoView: ProtoViewBuilder = null;
propertyBindings: Map<string, ASTWithSource> = new Map(); propertyBindings: Map<string, ASTWithSource> = new Map();
variableBindings: Map<string, string> = new Map(); variableBindings: Map<string, string> = new Map();
eventBindings: List<EventBinding> = []; eventBindings: EventBinding[] = [];
eventBuilder: EventBuilder = new EventBuilder(); eventBuilder: EventBuilder = new EventBuilder();
textBindings: Map<Node, ASTWithSource> = new Map(); textBindings: Map<Node, ASTWithSource> = new Map();
readAttributes: Map<string, string> = new Map(); readAttributes: Map<string, string> = new Map();
@ -233,9 +232,9 @@ export class DirectiveBuilder {
// mapping from directive property name to AST for that directive // mapping from directive property name to AST for that directive
propertyBindings: Map<string, ASTWithSource> = new Map(); propertyBindings: Map<string, ASTWithSource> = new Map();
// property names used in the template // property names used in the template
templatePropertyNames: List<string> = []; templatePropertyNames: string[] = [];
hostPropertyBindings: Map<string, ASTWithSource> = new Map(); hostPropertyBindings: Map<string, ASTWithSource> = new Map();
eventBindings: List<EventBinding> = []; eventBindings: EventBinding[] = [];
eventBuilder: EventBuilder = new EventBuilder(); eventBuilder: EventBuilder = new EventBuilder();
constructor(public directiveIndex: number) {} constructor(public directiveIndex: number) {}
@ -259,9 +258,9 @@ export class DirectiveBuilder {
} }
class EventBuilder extends AstTransformer { class EventBuilder extends AstTransformer {
locals: List<AST> = []; locals: AST[] = [];
localEvents: List<Event> = []; localEvents: Event[] = [];
globalEvents: List<Event> = []; globalEvents: Event[] = [];
_implicitReceiver: AST = new ImplicitReceiver(); _implicitReceiver: AST = new ImplicitReceiver();
constructor() { super(); } constructor() { super(); }
@ -303,19 +302,19 @@ class EventBuilder extends AstTransformer {
} }
} }
buildEventLocals(): List<AST> { return this.locals; } buildEventLocals(): AST[] { return this.locals; }
buildLocalEvents(): List<Event> { return this.localEvents; } buildLocalEvents(): Event[] { return this.localEvents; }
buildGlobalEvents(): List<Event> { return this.globalEvents; } buildGlobalEvents(): Event[] { return this.globalEvents; }
merge(eventBuilder: EventBuilder) { merge(eventBuilder: EventBuilder) {
this._merge(this.localEvents, eventBuilder.localEvents); this._merge(this.localEvents, eventBuilder.localEvents);
this._merge(this.globalEvents, eventBuilder.globalEvents); this._merge(this.globalEvents, eventBuilder.globalEvents);
ListWrapper.concat(this.locals, eventBuilder.locals); this.locals.concat(eventBuilder.locals);
} }
_merge(host: List<Event>, tobeAdded: List<Event>) { _merge(host: Event[], tobeAdded: Event[]) {
var names = []; var names = [];
for (var i = 0; i < host.length; i++) { for (var i = 0; i < host.length; i++) {
names.push(host[i].fullName); names.push(host[i].fullName);
@ -336,7 +335,7 @@ const STYLE_PREFIX = 'style';
function buildElementPropertyBindings( function buildElementPropertyBindings(
schemaRegistry: ElementSchemaRegistry, protoElement: /*element*/ any, isNgComponent: boolean, schemaRegistry: ElementSchemaRegistry, protoElement: /*element*/ any, isNgComponent: boolean,
bindingsInTemplate: Map<string, ASTWithSource>, directiveTemplatePropertyNames: Set<string>): bindingsInTemplate: Map<string, ASTWithSource>, directiveTemplatePropertyNames: Set<string>):
List<ElementPropertyBinding> { ElementPropertyBinding[] {
var propertyBindings = []; var propertyBindings = [];
MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => { MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => {

View File

@ -25,7 +25,7 @@ import {
import {TemplateCloner} from '../template_cloner'; import {TemplateCloner} from '../template_cloner';
export function mergeProtoViewsRecursively(templateCloner: TemplateCloner, export function mergeProtoViewsRecursively(templateCloner: TemplateCloner,
protoViewRefs: List<RenderProtoViewRef | List<any>>): protoViewRefs: Array<RenderProtoViewRef | any[]>):
RenderProtoViewMergeMapping { RenderProtoViewMergeMapping {
// clone // clone
var clonedProtoViews = []; var clonedProtoViews = [];
@ -77,7 +77,7 @@ export function mergeProtoViewsRecursively(templateCloner: TemplateCloner,
} }
function cloneProtoViews( function cloneProtoViews(
templateCloner: TemplateCloner, protoViewRefs: List<RenderProtoViewRef | List<any>>, templateCloner: TemplateCloner, protoViewRefs: Array<RenderProtoViewRef | any[]>,
targetClonedProtoViews: ClonedProtoView[], targetHostViewAndBinderIndices: number[][]) { targetClonedProtoViews: ClonedProtoView[], targetHostViewAndBinderIndices: number[][]) {
var hostProtoView = resolveInternalDomProtoView(protoViewRefs[0]); var hostProtoView = resolveInternalDomProtoView(protoViewRefs[0]);
var hostPvIdx = targetClonedProtoViews.length; var hostPvIdx = targetClonedProtoViews.length;

View File

@ -1,11 +1,5 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import { import {ListWrapper, MapWrapper, Map, StringMapWrapper} from 'angular2/src/core/facade/collection';
ListWrapper,
MapWrapper,
Map,
StringMapWrapper,
List
} from 'angular2/src/core/facade/collection';
import {isPresent, isBlank, BaseException, stringify} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, BaseException, stringify} from 'angular2/src/core/facade/lang';
import {DomProtoView} from './proto_view'; import {DomProtoView} from './proto_view';
@ -27,9 +21,9 @@ export class DomViewRef extends RenderViewRef {
export class DomView { export class DomView {
hydrated: boolean = false; hydrated: boolean = false;
eventDispatcher: RenderEventDispatcher = null; eventDispatcher: RenderEventDispatcher = null;
eventHandlerRemovers: List<Function> = []; eventHandlerRemovers: Function[] = [];
constructor(public proto: DomProtoView, public boundTextNodes: List<Node>, constructor(public proto: DomProtoView, public boundTextNodes: Node[],
public boundElements: Element[]) {} public boundElements: Element[]) {}
setElementProperty(elementIndex: number, propertyName: string, value: any) { setElementProperty(elementIndex: number, propertyName: string, value: any) {
@ -65,7 +59,7 @@ export class DomView {
} }
} }
invokeElementMethod(elementIndex: number, methodName: string, args: List<any>) { invokeElementMethod(elementIndex: number, methodName: string, args: any[]) {
var element = this.boundElements[elementIndex]; var element = this.boundElements[elementIndex];
DOM.invoke(element, methodName, args); DOM.invoke(element, methodName, args);
} }

View File

@ -1,8 +1,8 @@
import {ListWrapper, MapWrapper, List} from 'angular2/src/core/facade/collection'; import {ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
import * as viewModule from './view'; import * as viewModule from './view';
export class DomViewContainer { export class DomViewContainer {
// The order in this list matches the DOM order. // The order in this list matches the DOM order.
views: List<viewModule.DomView> = []; views: Array<viewModule.DomView> = [];
} }

View File

@ -1,12 +1,12 @@
import {XHR} from 'angular2/src/core/render/xhr'; import {XHR} from 'angular2/src/core/render/xhr';
import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, Map, MapWrapper} from 'angular2/src/core/facade/collection';
import {isBlank, isPresent, normalizeBlank, BaseException} from 'angular2/src/core/facade/lang'; import {isBlank, isPresent, normalizeBlank, BaseException} from 'angular2/src/core/facade/lang';
import {PromiseCompleter, PromiseWrapper, Promise} from 'angular2/src/core/facade/async'; import {PromiseCompleter, PromiseWrapper, Promise} from 'angular2/src/core/facade/async';
export class MockXHR extends XHR { export class MockXHR extends XHR {
private _expectations: List<_Expectation>; private _expectations: _Expectation[];
private _definitions: Map<string, string>; private _definitions: Map<string, string>;
private _requests: List<_PendingRequest>; private _requests: _PendingRequest[];
constructor() { constructor() {
super(); super();

View File

@ -200,7 +200,7 @@ enum _ComponentIndex {
* on the browser's regular expression implementation. Never null, since * on the browser's regular expression implementation. Never null, since
* arbitrary strings may still look like path names. * arbitrary strings may still look like path names.
*/ */
function _split(uri: string): List<string | any> { function _split(uri: string): Array<string | any> {
return RegExpWrapper.firstMatch(_splitRe, uri); return RegExpWrapper.firstMatch(_splitRe, uri);
} }
@ -255,7 +255,7 @@ function _removeDotSegments(path: string): string {
* @param {Array.<string?>} parts * @param {Array.<string?>} parts
* @return {string} * @return {string}
*/ */
function _joinAndCanonicalizePath(parts: List<any>): string { function _joinAndCanonicalizePath(parts: any[]): string {
var path = parts[_ComponentIndex.Path]; var path = parts[_ComponentIndex.Path];
path = isBlank(path) ? '' : _removeDotSegments(path); path = isBlank(path) ? '' : _removeDotSegments(path);
parts[_ComponentIndex.Path] = path; parts[_ComponentIndex.Path] = path;

View File

@ -8,7 +8,7 @@ class PublicTestability {
whenStable(callback: Function) { this._testability.whenStable(callback); } whenStable(callback: Function) { this._testability.whenStable(callback); }
findBindings(using: any, binding: string, exactMatch: boolean): List<any> { findBindings(using: any, binding: string, exactMatch: boolean): any[] {
return this._testability.findBindings(using, binding, exactMatch); return this._testability.findBindings(using, binding, exactMatch);
} }
} }
@ -24,7 +24,7 @@ export class GetTestability {
} }
return new PublicTestability(testability); return new PublicTestability(testability);
}; };
global.getAllAngularTestabilities = function(): List<PublicTestability> { global.getAllAngularTestabilities = function(): PublicTestability[] {
var testabilities = registry.getAllTestabilities(); var testabilities = registry.getAllTestabilities();
return testabilities.map((testability) => { return new PublicTestability(testability); }); return testabilities.map((testability) => { return new PublicTestability(testability); });
}; };

View File

@ -1,6 +1,6 @@
import {Injectable} from 'angular2/di'; import {Injectable} from 'angular2/di';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/core/facade/collection'; import {Map, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {StringWrapper, isBlank, BaseException} from 'angular2/src/core/facade/lang'; import {StringWrapper, isBlank, BaseException} from 'angular2/src/core/facade/lang';
import * as getTestabilityModule from './get_testability'; import * as getTestabilityModule from './get_testability';
import {NgZone} from '../zone/ng_zone'; import {NgZone} from '../zone/ng_zone';
@ -15,7 +15,7 @@ import {PromiseWrapper} from 'angular2/src/core/facade/async';
@Injectable() @Injectable()
export class Testability { export class Testability {
_pendingCount: number = 0; _pendingCount: number = 0;
_callbacks: List<Function> = []; _callbacks: Function[] = [];
_isAngularEventPending: boolean = false; _isAngularEventPending: boolean = false;
constructor(public _ngZone: NgZone) { this._watchAngularEvents(_ngZone); } constructor(public _ngZone: NgZone) { this._watchAngularEvents(_ngZone); }
@ -66,7 +66,7 @@ export class Testability {
// check for stability. // check for stability.
isAngularEventPending(): boolean { return this._isAngularEventPending; } isAngularEventPending(): boolean { return this._isAngularEventPending; }
findBindings(using: any, binding: string, exactMatch: boolean): List<any> { findBindings(using: any, binding: string, exactMatch: boolean): any[] {
// TODO(juliemr): implement. // TODO(juliemr): implement.
return []; return [];
} }
@ -82,7 +82,7 @@ export class TestabilityRegistry {
this._applications.set(token, testability); this._applications.set(token, testability);
} }
getAllTestabilities(): List<Testability> { return MapWrapper.values(this._applications); } getAllTestabilities(): Testability[] { return MapWrapper.values(this._applications); }
findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability { findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability {
if (elem == null) { if (elem == null) {

View File

@ -18,7 +18,7 @@ export interface ClassDefinition {
* *
* See {@link Class} for example of usage. * See {@link Class} for example of usage.
*/ */
constructor: (Function | Array<any>); constructor: (Function | any[]);
} }
/** /**
@ -60,7 +60,7 @@ export interface TypeDecorator {
* *
* Used by {@link Class} to annotate the generated class. * Used by {@link Class} to annotate the generated class.
*/ */
annotations: Array<any>; annotations: any[];
/** /**
* Generate a class from the definition and annotate it with {@link TypeDecorator#annotations}. * Generate a class from the definition and annotate it with {@link TypeDecorator#annotations}.
@ -76,7 +76,7 @@ function extractAnnotation(annotation: any): any {
return annotation; return annotation;
} }
function applyParams(fnOrArray: (Function | Array<any>), key: string): Function { function applyParams(fnOrArray: (Function | any[]), key: string): Function {
if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function || if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
fnOrArray === Number || fnOrArray === Array) { fnOrArray === Number || fnOrArray === Array) {
throw new Error(`Can not use native ${stringify(fnOrArray)} as constructor`); throw new Error(`Can not use native ${stringify(fnOrArray)} as constructor`);
@ -84,7 +84,7 @@ function applyParams(fnOrArray: (Function | Array<any>), key: string): Function
if (isFunction(fnOrArray)) { if (isFunction(fnOrArray)) {
return <Function>fnOrArray; return <Function>fnOrArray;
} else if (fnOrArray instanceof Array) { } else if (fnOrArray instanceof Array) {
var annotations: Array<any> = fnOrArray; var annotations: any[] = fnOrArray;
var fn: Function = fnOrArray[fnOrArray.length - 1]; var fn: Function = fnOrArray[fnOrArray.length - 1];
if (!isFunction(fn)) { if (!isFunction(fn)) {
throw new Error( throw new Error(
@ -95,9 +95,9 @@ function applyParams(fnOrArray: (Function | Array<any>), key: string): Function
throw new Error( throw new Error(
`Number of annotations (${annoLength}) does not match number of arguments (${fn.length}) in the function: ${stringify(fn)}`); `Number of annotations (${annoLength}) does not match number of arguments (${fn.length}) in the function: ${stringify(fn)}`);
} }
var paramsAnnotations: Array<Array<any>> = []; var paramsAnnotations: any[][] = [];
for (var i = 0, ii = annotations.length - 1; i < ii; i++) { for (var i = 0, ii = annotations.length - 1; i < ii; i++) {
var paramAnnotations: Array<any> = []; var paramAnnotations: any[] = [];
paramsAnnotations.push(paramAnnotations); paramsAnnotations.push(paramAnnotations);
var annotation = annotations[i]; var annotation = annotations[i];
if (annotation instanceof Array) { if (annotation instanceof Array) {
@ -270,7 +270,7 @@ export function makeParamDecorator(annotationCls): any {
function ParamDecorator(cls, unusedKey, index): any { function ParamDecorator(cls, unusedKey, index): any {
var parameters: Array<Array<any>> = Reflect.getMetadata('parameters', cls); var parameters: any[][] = Reflect.getMetadata('parameters', cls);
parameters = parameters || []; parameters = parameters || [];
// there might be gaps if some in between parameters do not have annotations. // there might be gaps if some in between parameters do not have annotations.
@ -280,7 +280,7 @@ export function makeParamDecorator(annotationCls): any {
} }
parameters[index] = parameters[index] || []; parameters[index] = parameters[index] || [];
var annotationsForParam: Array<any> = parameters[index]; var annotationsForParam: any[] = parameters[index];
annotationsForParam.push(annotationInstance); annotationsForParam.push(annotationInstance);
Reflect.defineMetadata('parameters', parameters, cls); Reflect.defineMetadata('parameters', parameters, cls);

View File

@ -1,4 +1,4 @@
import {List, ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {normalizeBlank, isPresent, global} from 'angular2/src/core/facade/lang'; import {normalizeBlank, isPresent, global} from 'angular2/src/core/facade/lang';
import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../profile/profile'; import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../profile/profile';
@ -45,7 +45,7 @@ export class NgZone {
_inVmTurnDone: boolean = false; _inVmTurnDone: boolean = false;
_pendingTimeouts: List<number> = []; _pendingTimeouts: number[] = [];
/** /**
* Associates with this * Associates with this

View File

@ -35,7 +35,7 @@ export {NgValidator, NgRequiredValidator} from './directives/validators';
* *
* This is a shorthand for importing them each individually. * This is a shorthand for importing them each individually.
*/ */
export const FORM_DIRECTIVES: List<Type> = CONST_EXPR([ export const FORM_DIRECTIVES: Type[] = CONST_EXPR([
NgControlName, NgControlName,
NgControlGroup, NgControlGroup,

View File

@ -1,6 +1,5 @@
import {Form} from './form_interface'; import {Form} from './form_interface';
import {AbstractControlDirective} from './abstract_control_directive'; import {AbstractControlDirective} from './abstract_control_directive';
import {List} from 'angular2/src/core/facade/collection';
/** /**
* A directive that contains a group of [NgControl]. * A directive that contains a group of [NgControl].
@ -10,5 +9,5 @@ import {List} from 'angular2/src/core/facade/collection';
export class ControlContainer extends AbstractControlDirective { export class ControlContainer extends AbstractControlDirective {
name: string; name: string;
get formDirective(): Form { return null; } get formDirective(): Form { return null; }
get path(): List<string> { return null; } get path(): string[] { return null; }
} }

View File

@ -11,7 +11,7 @@ export class NgControl extends AbstractControlDirective {
valueAccessor: ControlValueAccessor = null; valueAccessor: ControlValueAccessor = null;
get validator(): Function { return null; } get validator(): Function { return null; }
get path(): List<string> { return null; } get path(): string[] { return null; }
viewToModelUpdate(newValue: any): void {} viewToModelUpdate(newValue: any): void {}
} }

View File

@ -1,6 +1,6 @@
import {Directive, LifecycleEvent} from 'angular2/metadata'; import {Directive, LifecycleEvent} from 'angular2/metadata';
import {Inject, Host, SkipSelf, forwardRef, Binding} from 'angular2/di'; import {Inject, Host, SkipSelf, forwardRef, Binding} from 'angular2/di';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {CONST_EXPR} from 'angular2/src/core/facade/lang'; import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {ControlContainer} from './control_container'; import {ControlContainer} from './control_container';
@ -68,7 +68,7 @@ export class NgControlGroup extends ControlContainer {
get control(): ControlGroup { return this.formDirective.getControlGroup(this); } get control(): ControlGroup { return this.formDirective.getControlGroup(this); }
get path(): List<string> { return controlPath(this.name, this._parent); } get path(): string[] { return controlPath(this.name, this._parent); }
get formDirective(): Form { return this._parent.formDirective; } get formDirective(): Form { return this._parent.formDirective; }
} }

View File

@ -1,6 +1,6 @@
import {CONST_EXPR} from 'angular2/src/core/facade/lang'; import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
import {List, StringMap} from 'angular2/src/core/facade/collection'; import {StringMap} from 'angular2/src/core/facade/collection';
import {QueryList} from 'angular2/core'; import {QueryList} from 'angular2/core';
import {Query, Directive, LifecycleEvent} from 'angular2/metadata'; import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
@ -113,7 +113,7 @@ export class NgControlName extends NgControl {
ObservableWrapper.callNext(this.update, newValue); ObservableWrapper.callNext(this.update, newValue);
} }
get path(): List<string> { return controlPath(this.name, this._parent); } get path(): string[] { return controlPath(this.name, this._parent); }
get formDirective(): any { return this._parent.formDirective; } get formDirective(): any { return this._parent.formDirective; }

View File

@ -4,7 +4,7 @@ import {
EventEmitter, EventEmitter,
PromiseCompleter PromiseCompleter
} from 'angular2/src/core/facade/async'; } from 'angular2/src/core/facade/async';
import {StringMapWrapper, List, ListWrapper} from 'angular2/src/core/facade/collection'; import {StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang'; import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';
import {Directive} from 'angular2/metadata'; import {Directive} from 'angular2/metadata';
import {forwardRef, Binding} from 'angular2/di'; import {forwardRef, Binding} from 'angular2/di';
@ -72,7 +72,7 @@ export class NgForm extends ControlContainer implements Form {
get control(): ControlGroup { return this.form; } get control(): ControlGroup { return this.form; }
get path(): List<string> { return []; } get path(): string[] { return []; }
get controls(): StringMap<string, AbstractControl> { return this.form.controls; } get controls(): StringMap<string, AbstractControl> { return this.form.controls; }
@ -133,7 +133,7 @@ export class NgForm extends ControlContainer implements Form {
return false; return false;
} }
_findContainer(path: List<string>): ControlGroup { _findContainer(path: string[]): ControlGroup {
ListWrapper.removeLast(path); ListWrapper.removeLast(path);
return ListWrapper.isEmpty(path) ? this.form : <ControlGroup>this.form.find(path); return ListWrapper.isEmpty(path) ? this.form : <ControlGroup>this.form.find(path);
} }

View File

@ -91,7 +91,7 @@ export class NgFormControl extends NgControl {
} }
} }
get path(): List<string> { return []; } get path(): string[] { return []; }
get control(): Control { return this.form; } get control(): Control { return this.form; }

View File

@ -1,5 +1,5 @@
import {CONST_EXPR} from 'angular2/src/core/facade/lang'; import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {List, ListWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper} from 'angular2/src/core/facade/collection';
import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async'; import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async';
import {Directive, LifecycleEvent} from 'angular2/metadata'; import {Directive, LifecycleEvent} from 'angular2/metadata';
@ -93,7 +93,7 @@ const formDirectiveBinding =
}) })
export class NgFormModel extends ControlContainer implements Form { export class NgFormModel extends ControlContainer implements Form {
form: ControlGroup = null; form: ControlGroup = null;
directives: List<NgControl> = []; directives: NgControl[] = [];
ngSubmit = new EventEmitter(); ngSubmit = new EventEmitter();
onChanges(_) { this._updateDomValue(); } onChanges(_) { this._updateDomValue(); }
@ -102,7 +102,7 @@ export class NgFormModel extends ControlContainer implements Form {
get control(): ControlGroup { return this.form; } get control(): ControlGroup { return this.form; }
get path(): List<string> { return []; } get path(): string[] { return []; }
addControl(dir: NgControl): void { addControl(dir: NgControl): void {
var c: any = this.form.find(dir.path); var c: any = this.form.find(dir.path);

View File

@ -64,7 +64,7 @@ export class NgModel extends NgControl {
get control(): Control { return this._control; } get control(): Control { return this._control; }
get path(): List<string> { return []; } get path(): string[] { return []; }
get validator(): Function { return composeNgValidator(this.ngValidators); } get validator(): Function { return composeNgValidator(this.ngValidators); }

View File

@ -1,5 +1,5 @@
import {Injectable} from 'angular2/di'; import {Injectable} from 'angular2/di';
import {StringMapWrapper, ListWrapper, List} from 'angular2/src/core/facade/collection'; import {StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {isPresent, isArray} from 'angular2/src/core/facade/lang'; import {isPresent, isArray} from 'angular2/src/core/facade/lang';
import * as modelModule from './model'; import * as modelModule from './model';
@ -91,7 +91,7 @@ export class FormBuilder {
} }
} }
array(controlsConfig: List<any>, validator: Function = null): modelModule.ControlArray { array(controlsConfig: any[], validator: Function = null): modelModule.ControlArray {
var controls = ListWrapper.map(controlsConfig, (c) => this._createControl(c)); var controls = ListWrapper.map(controlsConfig, (c) => this._createControl(c));
if (isPresent(validator)) { if (isPresent(validator)) {
return new modelModule.ControlArray(controls, validator); return new modelModule.ControlArray(controls, validator);
@ -115,7 +115,7 @@ export class FormBuilder {
return controlConfig; return controlConfig;
} else if (isArray(controlConfig)) { } else if (isArray(controlConfig)) {
var value = ListWrapper.get(controlConfig, 0); var value = controlConfig[0];
var validator = controlConfig.length > 1 ? controlConfig[1] : null; var validator = controlConfig.length > 1 ? controlConfig[1] : null;
return this.control(value, validator); return this.control(value, validator);

View File

@ -1,6 +1,6 @@
import {StringWrapper, isPresent, isBlank} from 'angular2/src/core/facade/lang'; import {StringWrapper, isPresent, isBlank} from 'angular2/src/core/facade/lang';
import {Observable, EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; import {Observable, EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
import {StringMap, StringMapWrapper, ListWrapper, List} from 'angular2/src/core/facade/collection'; import {StringMap, StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {Validators} from './validators'; import {Validators} from './validators';
/** /**
@ -17,14 +17,14 @@ export function isControl(c: Object): boolean {
return c instanceof AbstractControl; return c instanceof AbstractControl;
} }
function _find(c: AbstractControl, path: List<string | number>| string) { function _find(c: AbstractControl, path: Array<string | number>| string) {
if (isBlank(path)) return null; if (isBlank(path)) return null;
if (!(path instanceof List)) { if (!(path instanceof Array)) {
path = StringWrapper.split(<string>path, new RegExp("/")); path = StringWrapper.split(<string>path, new RegExp("/"));
} }
if (path instanceof List && ListWrapper.isEmpty(path)) return null; if (path instanceof Array && ListWrapper.isEmpty(path)) return null;
return ListWrapper.reduce(<List<string | number>>path, (v, name) => { return ListWrapper.reduce(<Array<string | number>>path, (v, name) => {
if (v instanceof ControlGroup) { if (v instanceof ControlGroup) {
return isPresent(v.controls[name]) ? v.controls[name] : null; return isPresent(v.controls[name]) ? v.controls[name] : null;
} else if (v instanceof ControlArray) { } else if (v instanceof ControlArray) {
@ -116,9 +116,9 @@ export class AbstractControl {
} }
} }
find(path: List<string | number>| string): AbstractControl { return _find(this, path); } find(path: Array<string | number>| string): AbstractControl { return _find(this, path); }
getError(errorCode: string, path: List<string> = null): any { getError(errorCode: string, path: string[] = null): any {
var c = isPresent(path) && !ListWrapper.isEmpty(path) ? this.find(path) : this; var c = isPresent(path) && !ListWrapper.isEmpty(path) ? this.find(path) : this;
if (isPresent(c) && isPresent(c._errors)) { if (isPresent(c) && isPresent(c._errors)) {
return StringMapWrapper.get(c._errors, errorCode); return StringMapWrapper.get(c._errors, errorCode);
@ -127,7 +127,7 @@ export class AbstractControl {
} }
} }
hasError(errorCode: string, path: List<string> = null): boolean { hasError(errorCode: string, path: string[] = null): boolean {
return isPresent(this.getError(errorCode, path)); return isPresent(this.getError(errorCode, path));
} }
@ -183,8 +183,8 @@ export class ControlGroup extends AbstractControl {
controls: StringMap<string, AbstractControl>; controls: StringMap<string, AbstractControl>;
_optionals: StringMap<string, boolean>; _optionals: StringMap<string, boolean>;
constructor(controls: StringMap<String, AbstractControl>, constructor(controls: StringMap<string, AbstractControl>,
optionals: StringMap<String, boolean> = null, optionals: StringMap<string, boolean> = null,
validator: Function = Validators.group) { validator: Function = Validators.group) {
super(validator); super(validator);
this.controls = controls; this.controls = controls;
@ -262,9 +262,9 @@ export class ControlGroup extends AbstractControl {
* other controls, but is of fixed length. * other controls, but is of fixed length.
*/ */
export class ControlArray extends AbstractControl { export class ControlArray extends AbstractControl {
controls: List<AbstractControl>; controls: AbstractControl[];
constructor(controls: List<AbstractControl>, validator: Function = Validators.array) { constructor(controls: AbstractControl[], validator: Function = Validators.array) {
super(validator); super(validator);
this.controls = controls; this.controls = controls;

View File

@ -1,5 +1,5 @@
import {isBlank, isPresent} from 'angular2/src/core/facade/lang'; import {isBlank, isPresent} from 'angular2/src/core/facade/lang';
import {List, ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import * as modelModule from './model'; import * as modelModule from './model';
@ -19,7 +19,7 @@ export class Validators {
static nullValidator(c: any): StringMap<string, boolean> { return null; } static nullValidator(c: any): StringMap<string, boolean> { return null; }
static compose(validators: List<Function>): Function { static compose(validators: Function[]): Function {
return function(c: modelModule.Control) { return function(c: modelModule.Control) {
var res = ListWrapper.reduce(validators, (res, validator) => { var res = ListWrapper.reduce(validators, (res, validator) => {
var errors = validator(c); var errors = validator(c);

View File

@ -170,7 +170,7 @@ export class MockBackend implements ConnectionBackend {
* *
* This property only exists in the mock implementation, not in real Backends. * This property only exists in the mock implementation, not in real Backends.
*/ */
connectionsArray: Array<MockConnection>; connectionsArray: MockConnection[];
/** /**
* {@link EventEmitter} of {@link MockConnection} instances that haven't yet been resolved (i.e. * {@link EventEmitter} of {@link MockConnection} instances that haven't yet been resolved (i.e.
* with a `readyState` * with a `readyState`

View File

@ -8,7 +8,6 @@ import {
} from 'angular2/src/core/facade/lang'; } from 'angular2/src/core/facade/lang';
import { import {
isListLikeIterable, isListLikeIterable,
List,
Map, Map,
MapWrapper, MapWrapper,
ListWrapper, ListWrapper,
@ -21,7 +20,7 @@ import {
* difference from the spec is the lack of an `entries` method. * difference from the spec is the lack of an `entries` method.
*/ */
export class Headers { export class Headers {
_headersMap: Map<string, List<string>>; _headersMap: Map<string, string[]>;
constructor(headers?: Headers | StringMap<string, any>) { constructor(headers?: Headers | StringMap<string, any>) {
if (isBlank(headers)) { if (isBlank(headers)) {
this._headersMap = new Map(); this._headersMap = new Map();
@ -31,7 +30,7 @@ export class Headers {
if (headers instanceof Headers) { if (headers instanceof Headers) {
this._headersMap = (<Headers>headers)._headersMap; this._headersMap = (<Headers>headers)._headersMap;
} else if (headers instanceof StringMap) { } else if (headers instanceof StringMap) {
this._headersMap = MapWrapper.createFromStringMap<List<string>>(headers); this._headersMap = MapWrapper.createFromStringMap<string[]>(headers);
MapWrapper.forEach(this._headersMap, (v, k) => { MapWrapper.forEach(this._headersMap, (v, k) => {
if (!isListLikeIterable(v)) { if (!isListLikeIterable(v)) {
var list = []; var list = [];
@ -72,16 +71,16 @@ export class Headers {
/** /**
* Provides names of set headers * Provides names of set headers
*/ */
keys(): List<string> { return MapWrapper.keys(this._headersMap); } keys(): string[] { return MapWrapper.keys(this._headersMap); }
/** /**
* Sets or overrides header value for given name. * Sets or overrides header value for given name.
*/ */
set(header: string, value: string | List<string>): void { set(header: string, value: string | string[]): void {
var list = []; var list = [];
if (isListLikeIterable(value)) { if (isListLikeIterable(value)) {
var pushValue = (<List<string>>value).join(','); var pushValue = (<string[]>value).join(',');
list.push(pushValue); list.push(pushValue);
} else { } else {
list.push(value); list.push(value);
@ -93,12 +92,12 @@ export class Headers {
/** /**
* Returns values of all headers. * Returns values of all headers.
*/ */
values(): List<List<string>> { return MapWrapper.values(this._headersMap); } values(): string[][] { return MapWrapper.values(this._headersMap); }
/** /**
* Returns list of header values for a given name. * Returns list of header values for a given name.
*/ */
getAll(header: string): Array<string> { getAll(header: string): string[] {
var headers = this._headersMap.get(header); var headers = this._headersMap.get(header);
return isListLikeIterable(headers) ? headers : []; return isListLikeIterable(headers) ? headers : [];
} }

Some files were not shown because too many files have changed in this diff Show More