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:
@ -35,7 +35,7 @@ function _convertLocalsToVariableBindings(locals: Locals): List<any> {
|
||||
var variableBindings = [];
|
||||
var loc = locals;
|
||||
while (isPresent(loc) && isPresent(loc.current)) {
|
||||
MapWrapper.forEach(loc.current, (v, k) => ListWrapper.push(variableBindings, k));
|
||||
MapWrapper.forEach(loc.current, (v, k) => variableBindings.push(k));
|
||||
loc = loc.parent;
|
||||
}
|
||||
return variableBindings;
|
||||
|
@ -455,9 +455,9 @@ export function main() {
|
||||
|
||||
var onChangesDoneCalls = [];
|
||||
var td1;
|
||||
td1 = new TestDirective(() => ListWrapper.push(onChangesDoneCalls, td1));
|
||||
td1 = new TestDirective(() => onChangesDoneCalls.push(td1));
|
||||
var td2;
|
||||
td2 = new TestDirective(() => ListWrapper.push(onChangesDoneCalls, td2));
|
||||
td2 = new TestDirective(() => onChangesDoneCalls.push(td2));
|
||||
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([td1, td2], []));
|
||||
|
||||
cd.detectChanges();
|
||||
@ -473,11 +473,11 @@ export function main() {
|
||||
var orderOfOperations = [];
|
||||
|
||||
var directiveInShadowDom = null;
|
||||
directiveInShadowDom = new TestDirective(
|
||||
() => { ListWrapper.push(orderOfOperations, directiveInShadowDom); });
|
||||
directiveInShadowDom =
|
||||
new TestDirective(() => { orderOfOperations.push(directiveInShadowDom); });
|
||||
var parentDirective = null;
|
||||
parentDirective = new TestDirective(
|
||||
() => { ListWrapper.push(orderOfOperations, parentDirective); });
|
||||
parentDirective =
|
||||
new TestDirective(() => { orderOfOperations.push(parentDirective); });
|
||||
|
||||
parent.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([parentDirective], []));
|
||||
child.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directiveInShadowDom], []));
|
||||
@ -989,14 +989,14 @@ class TestDispatcher extends ChangeDispatcher {
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.log = ListWrapper.create();
|
||||
this.loggedValues = ListWrapper.create();
|
||||
this.log = [];
|
||||
this.loggedValues = [];
|
||||
this.onAllChangesDoneCalled = true;
|
||||
}
|
||||
|
||||
notifyOnBinding(binding, value) {
|
||||
ListWrapper.push(this.log, `${binding.propertyName}=${this._asString(value)}`);
|
||||
ListWrapper.push(this.loggedValues, value);
|
||||
this.log.push(`${binding.propertyName}=${this._asString(value)}`);
|
||||
this.loggedValues.push(value);
|
||||
}
|
||||
|
||||
notifyOnAllChangesDone() { this.onAllChangesDoneCalled = true; }
|
||||
|
@ -63,7 +63,7 @@ export function main() {
|
||||
var c = isBlank(passedInContext) ? td() : passedInContext;
|
||||
var res = [];
|
||||
for (var i = 0; i < asts.length; i++) {
|
||||
ListWrapper.push(res, asts[i].eval(c, emptyLocals()));
|
||||
res.push(asts[i].eval(c, emptyLocals()));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import {
|
||||
IS_DARTIUM
|
||||
} from 'angular2/test_lib';
|
||||
import {Json, RegExp, NumberWrapper, StringWrapper} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {JsonPipe} from 'angular2/src/change_detection/pipes/json_pipe';
|
||||
|
||||
@ -26,7 +25,7 @@ export function main() {
|
||||
var inceptionObjString;
|
||||
var catString;
|
||||
var pipe;
|
||||
var collection;
|
||||
var collection: number[];
|
||||
|
||||
function normalize(obj: string): string { return StringWrapper.replace(obj, regNewLine, ''); }
|
||||
|
||||
@ -87,7 +86,7 @@ export function main() {
|
||||
|
||||
expect(pipe.transform(collection)).toEqual(stringCollection);
|
||||
|
||||
ListWrapper.push(collection, 1);
|
||||
collection.push(1);
|
||||
|
||||
expect(pipe.transform(collection)).toEqual(stringCollectionWith1);
|
||||
});
|
||||
|
Reference in New Issue
Block a user