feat(change_detection): do not reparse AST when using generated detectors

This commit is contained in:
vsavkin
2015-08-19 11:26:45 -07:00
parent b986c54079
commit d2d0715568
31 changed files with 423 additions and 279 deletions
@@ -30,12 +30,12 @@ export function main() {
var map = {'id': (def) => proto};
var cd = new PreGeneratedChangeDetection(map);
expect(cd.createProtoChangeDetector(def)).toBe(proto)
expect(cd.getProtoChangeDetector('id', def)).toBe(proto)
});
it("should delegate to dynamic change detection otherwise", () => {
var cd = new PreGeneratedChangeDetection({});
expect(cd.createProtoChangeDetector(def)).toBeAnInstanceOf(DynamicProtoChangeDetector);
expect(cd.getProtoChangeDetector('id', def)).toBeAnInstanceOf(DynamicProtoChangeDetector);
});
});
}
@@ -1135,8 +1135,8 @@ class TestDispatcher implements ChangeDispatcher {
this.onAllChangesDoneCalled = true;
}
notifyOnBinding(binding, value) {
this.log.push(`${binding.propertyName}=${this._asString(value)}`);
notifyOnBinding(target, value) {
this.log.push(`${target.name}=${this._asString(value)}`);
this.loggedValues.push(value);
}
@@ -21,8 +21,7 @@ export function main() {
if (isBlank(argumentToPureFunction)) argumentToPureFunction = false;
return new ProtoRecord(mode, name, funcOrValue, args, null, contextIndex, directiveIndex,
selfIndex, null, null, lastInBinding, false, argumentToPureFunction,
false);
selfIndex, null, lastInBinding, false, argumentToPureFunction, false, 0);
}
describe("change detection - coalesce", () => {
@@ -64,7 +63,7 @@ export function main() {
[r("user", [], 0, 1, {lastInBinding: true}), r("user", [], 0, 2, {lastInBinding: true})]);
expect(rs[1]).toEqual(new ProtoRecord(RecordType.SELF, "self", null, [], null, 1, null, 2,
null, null, true, false, false, false));
null, true, false, false, false, 0));
});
it("should set referencedBySelf", () => {
@@ -19,7 +19,7 @@ export function main() {
it('should set argumentToPureFunction flag', inject([Parser], (p: Parser) => {
var builder = new ProtoRecordBuilder();
var ast = p.parseBinding("[1,2]", "location"); // collection literal is a pure function
builder.add(BindingRecord.createForElementProperty(ast, 0, "property"), []);
builder.add(BindingRecord.createForElementProperty(ast, 0, "property"), [], 0);
var isPureFunc = builder.records.map(r => r.argumentToPureFunction);
expect(isPureFunc).toEqual([true, true, false]);
@@ -29,7 +29,7 @@ export function main() {
inject([Parser], (p: Parser) => {
var builder = new ProtoRecordBuilder();
var ast = p.parseBinding("f(1,2)", "location");
builder.add(BindingRecord.createForElementProperty(ast, 0, "property"), []);
builder.add(BindingRecord.createForElementProperty(ast, 0, "property"), [], 0);
var isPureFunc = builder.records.map(r => r.argumentToPureFunction);
expect(isPureFunc).toEqual([false, false, false]);
@@ -20,8 +20,8 @@ export function main() {
if (isBlank(argumentToPureFunction)) argumentToPureFunction = false;
if (isBlank(referencedBySelf)) referencedBySelf = false;
return new ProtoRecord(mode, name, null, [], null, 0, directiveIndex, 0, null, null,
lastInBinding, false, argumentToPureFunction, referencedBySelf);
return new ProtoRecord(mode, name, null, [], null, 0, directiveIndex, 0, null, lastInBinding,
false, argumentToPureFunction, referencedBySelf, 0);
}
describe("ProtoRecord", () => {