fix(compiler): take quoting into account when determining if object literals can be shared (#22942)

PR Close #22942
This commit is contained in:
Victor Berchet 2018-03-22 15:02:30 -07:00 committed by Matias Niemelä
parent 16f021c319
commit d98e9e7c7f
1 changed files with 6 additions and 2 deletions

View File

@ -227,8 +227,12 @@ class KeyVisitor implements o.ExpressionVisitor {
}
visitLiteralMapExpr(ast: o.LiteralMapExpr, context: object): string {
const mapEntry = (entry: o.LiteralMapEntry) =>
`${entry.key}:${entry.value.visitExpression(this, context)}`;
const mapKey =
(entry: o.LiteralMapEntry) => {
const quote = entry.quoted ? '"' : '';
return `${quote}${entry.key}${quote}`;
} const mapEntry = (entry: o.LiteralMapEntry) =>
`${mapKey(entry)}:${entry.value.visitExpression(this, context)}`;
return `{${ast.entries.map(mapEntry).join(',')}`;
}