Skip to content

Commit 45b33c5

Browse files
Tim Blasikegluneq
authored andcommitted
perf(dart/transform): Restrict visibility/mutability of codegen
For exported, generated templates, declare with `final` so `dart2js` knows they will never be reassigned. For non-exported, generated change detector classes, prefix the classname with `_` to mark them as internal. Closes #5009
1 parent 860e88c commit 45b33c5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

modules/angular2/src/core/compiler/change_detector_compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class ChangeDetectionCompiler {
6969
// and have the same API for calling them!
7070
if (IS_DART) {
7171
codegen = new Codegen(PREGEN_PROTO_CHANGE_DETECTOR_MODULE);
72-
var className = definition.id;
72+
var className = `_${definition.id}`;
7373
var typeRef = (index === 0 && componentType.isHost) ?
7474
'dynamic' :
7575
`${moduleRef(componentType.moduleUrl)}${componentType.name}`;

modules/angular2/src/core/compiler/util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ function escapeString(input: string, re: RegExp): string {
4646
}
4747

4848
export function codeGenExportVariable(name: string, isConst: boolean = false): string {
49-
var declaration = IS_DART && isConst ? `const ${name}` : `var ${name}`;
50-
return IS_DART ? `${declaration} = ` : `${declaration} = exports['${name}'] = `;
49+
if (IS_DART) {
50+
return isConst ? `const ${name} = ` : `final ${name} = `;
51+
} else {
52+
return `var ${name} = exports['${name}'] = `;
53+
}
5154
}
5255

5356
export function codeGenConcatArray(expression: string): string {

0 commit comments

Comments
 (0)