diff --git a/modules/angular2/src/change_detection/coalesce.ts b/modules/angular2/src/change_detection/coalesce.ts index 53d1d24957..300fc3914f 100644 --- a/modules/angular2/src/change_detection/coalesce.ts +++ b/modules/angular2/src/change_detection/coalesce.ts @@ -46,7 +46,7 @@ function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): P function _findMatching(r: ProtoRecord, rs: List) { return ListWrapper.find(rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE && 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)); } diff --git a/modules/angular2/test/change_detection/coalesce_spec.ts b/modules/angular2/test/change_detection/coalesce_spec.ts index bb3a88f7a1..310256a702 100644 --- a/modules/angular2/test/change_detection/coalesce_spec.ts +++ b/modules/angular2/test/change_detection/coalesce_spec.ts @@ -5,9 +5,9 @@ import {RecordType, ProtoRecord} from 'angular2/src/change_detection/proto_recor export function main() { function r(funcOrValue, args, contextIndex, selfIndex, lastInBinding = false, - mode = RecordType.PROPERTY) { - return new ProtoRecord(mode, "name", funcOrValue, args, null, contextIndex, null, selfIndex, - null, null, lastInBinding, false); + mode = RecordType.PROPERTY, name = "name") { + return new ProtoRecord(mode, name, funcOrValue, args, null, contextIndex, null, selfIndex, null, + null, lastInBinding, false); } describe("change detection - coalesce", () => { @@ -60,5 +60,14 @@ export function main() { 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); + }); }); }