fix(change detectors): Fix deduping of protos in transformed dart mode.

In non-transformed mode the funcOrValue check was enough, but once
transformed these all use the same function for getters, so we need
to also check the name.
This commit is contained in:
Jacob MacDonald 2015-06-30 14:13:50 -07:00
parent dcdd73065a
commit 73a939e76c
2 changed files with 13 additions and 4 deletions

View File

@ -46,7 +46,7 @@ function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): P
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) { function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) {
return ListWrapper.find(rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE && return ListWrapper.find(rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE &&
rr.mode === r.mode && rr.funcOrValue === r.funcOrValue && rr.mode === r.mode && rr.funcOrValue === r.funcOrValue &&
rr.contextIndex === r.contextIndex && rr.contextIndex === r.contextIndex && rr.name === r.name &&
ListWrapper.equals(rr.args, r.args)); ListWrapper.equals(rr.args, r.args));
} }

View File

@ -5,9 +5,9 @@ import {RecordType, ProtoRecord} from 'angular2/src/change_detection/proto_recor
export function main() { export function main() {
function r(funcOrValue, args, contextIndex, selfIndex, lastInBinding = false, function r(funcOrValue, args, contextIndex, selfIndex, lastInBinding = false,
mode = RecordType.PROPERTY) { mode = RecordType.PROPERTY, name = "name") {
return new ProtoRecord(mode, "name", funcOrValue, args, null, contextIndex, null, selfIndex, return new ProtoRecord(mode, name, funcOrValue, args, null, contextIndex, null, selfIndex, null,
null, null, lastInBinding, false); null, lastInBinding, false);
} }
describe("change detection - coalesce", () => { describe("change detection - coalesce", () => {
@ -60,5 +60,14 @@ export function main() {
expect(rs.length).toEqual(2); expect(rs.length).toEqual(2);
}); });
it("should not coalesce protos with different names but same value", () => {
var nullFunc = () => {};
var rs = coalesce([
r(nullFunc, [], 0, 1, false, RecordType.PROPERTY, "foo"),
r(nullFunc, [], 0, 1, false, RecordType.PROPERTY, "bar"),
]);
expect(rs.length).toEqual(2);
});
}); });
} }