chore: kill ListWrapper.create() and .push().

These wrappers are not natively understood by
ts2dart. Removing them will improve Dart2JS
compilation due to fewer megamorphic calls to List
functions.

It also makes Angular code more succinct and
improves type safety in Angular due to better type
inference of the Array component type.

This change exposed several bugs in Angular.
This commit is contained in:
Martin Probst
2015-06-17 11:17:21 -07:00
parent 6af41a4543
commit c7e48350d3
88 changed files with 360 additions and 387 deletions

View File

@ -113,7 +113,7 @@ export class NgFormModel extends ControlContainer implements Form {
var c: any = this.form.find(dir.path);
setUpControl(c, dir);
c.updateValidity();
ListWrapper.push(this.directives, dir);
this.directives.push(dir);
}
getControl(dir: NgControl): Control { return <Control>this.form.find(dir.path); }

View File

@ -10,7 +10,7 @@ import {Renderer, ElementRef} from 'angular2/angular2';
export function controlPath(name, parent: ControlContainer) {
var p = ListWrapper.clone(parent.path);
ListWrapper.push(p, name);
p.push(name);
return p;
}

View File

@ -287,7 +287,7 @@ export class ControlArray extends AbstractControl {
at(index: number): AbstractControl { return this.controls[index]; }
push(control: AbstractControl): void {
ListWrapper.push(this.controls, control);
this.controls.push(control);
control.setParent(this);
this.updateValueAndValidity();
}

View File

@ -51,12 +51,13 @@ export class Validators {
return StringMapWrapper.isEmpty(res) ? null : res;
}
static _mergeErrors(control: modelModule.AbstractControl, res: StringMap<string, any>): void {
static _mergeErrors(control: modelModule.AbstractControl, res: StringMap<string, any[]>): void {
StringMapWrapper.forEach(control.errors, (value, error) => {
if (!StringMapWrapper.contains(res, error)) {
res[error] = [];
}
ListWrapper.push(res[error], control);
var current: any[] = res[error];
current.push(control);
});
}
}