Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzmitry Shylovich authored and Dzmitry Shylovich committed Dec 29, 2016
1 parent 6042871 commit ee4ba8b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions modules/@angular/compiler/src/compile_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function _sanitizeIdentifier(name: string): string {
}

let _anonymousTypeIndex = 0;
const anonymousTypes = new WeakMap<any, string>();

export function identifierName(compileIdentifier: CompileIdentifierMetadata): string {
if (!compileIdentifier || !compileIdentifier.reference) {
Expand All @@ -91,15 +90,17 @@ export function identifierName(compileIdentifier: CompileIdentifierMetadata): st
if (ref instanceof StaticSymbol) {
return ref.name;
}
if (anonymousTypes.has(ref)) {
return anonymousTypes.get(ref);
if (typeof ref === 'symbol') {
return stringify(ref);
}

let identifier: string = stringify(ref);
if (ref['__anonymousType']) {
return ref['__anonymousType'];
}
let identifier = stringify(ref);
if (identifier.indexOf('(') >= 0) {
// case: anonymous functions or Symbol!
// case: anonymous functions!
identifier = `anonymous_${_anonymousTypeIndex++}`;
anonymousTypes.set(ref, identifier);
ref['__anonymousType'] = identifier;
} else {
identifier = _sanitizeIdentifier(identifier);
}
Expand Down

0 comments on commit ee4ba8b

Please sign in to comment.