Skip to content

Commit 73a939e

Browse files
committed
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.
1 parent dcdd730 commit 73a939e

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

modules/angular2/src/change_detection/coalesce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): P
4646
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) {
4747
return ListWrapper.find(rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE &&
4848
rr.mode === r.mode && rr.funcOrValue === r.funcOrValue &&
49-
rr.contextIndex === r.contextIndex &&
49+
rr.contextIndex === r.contextIndex && rr.name === r.name &&
5050
ListWrapper.equals(rr.args, r.args));
5151
}
5252

modules/angular2/test/change_detection/coalesce_spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {RecordType, ProtoRecord} from 'angular2/src/change_detection/proto_recor
55

66
export function main() {
77
function r(funcOrValue, args, contextIndex, selfIndex, lastInBinding = false,
8-
mode = RecordType.PROPERTY) {
9-
return new ProtoRecord(mode, "name", funcOrValue, args, null, contextIndex, null, selfIndex,
10-
null, null, lastInBinding, false);
8+
mode = RecordType.PROPERTY, name = "name") {
9+
return new ProtoRecord(mode, name, funcOrValue, args, null, contextIndex, null, selfIndex, null,
10+
null, lastInBinding, false);
1111
}
1212

1313
describe("change detection - coalesce", () => {
@@ -60,5 +60,14 @@ export function main() {
6060

6161
expect(rs.length).toEqual(2);
6262
});
63+
64+
it("should not coalesce protos with different names but same value", () => {
65+
var nullFunc = () => {};
66+
var rs = coalesce([
67+
r(nullFunc, [], 0, 1, false, RecordType.PROPERTY, "foo"),
68+
r(nullFunc, [], 0, 1, false, RecordType.PROPERTY, "bar"),
69+
]);
70+
expect(rs.length).toEqual(2);
71+
});
6372
});
6473
}

0 commit comments

Comments
 (0)