fix(compiler): emits quoted keys only iff they are quoted in the original template
fixes #14292
This commit is contained in:

committed by
Jason Aden

parent
798947efa4
commit
9c1f6fd06f
@ -476,7 +476,7 @@ export class LiteralArrayExpr extends Expression {
|
||||
}
|
||||
|
||||
export class LiteralMapEntry {
|
||||
constructor(public key: string, public value: Expression, public quoted: boolean = false) {}
|
||||
constructor(public key: string, public value: Expression, public quoted: boolean) {}
|
||||
}
|
||||
|
||||
export class LiteralMapExpr extends Expression {
|
||||
@ -831,7 +831,7 @@ export class AstTransformer implements StatementVisitor, ExpressionVisitor {
|
||||
visitLiteralMapExpr(ast: LiteralMapExpr, context: any): any {
|
||||
const entries = ast.entries.map(
|
||||
(entry): LiteralMapEntry => new LiteralMapEntry(
|
||||
entry.key, entry.value.visitExpression(this, context), entry.quoted, ));
|
||||
entry.key, entry.value.visitExpression(this, context), entry.quoted));
|
||||
const mapType = new MapType(ast.valueType, null);
|
||||
return this.transformExpr(new LiteralMapExpr(entries, mapType, ast.sourceSpan), context);
|
||||
}
|
||||
@ -1151,10 +1151,10 @@ export function literalArr(
|
||||
}
|
||||
|
||||
export function literalMap(
|
||||
values: [string, Expression][], type: MapType | null = null,
|
||||
quoted: boolean = false): LiteralMapExpr {
|
||||
values: {key: string, quoted: boolean, value: Expression}[],
|
||||
type: MapType | null = null): LiteralMapExpr {
|
||||
return new LiteralMapExpr(
|
||||
values.map(entry => new LiteralMapEntry(entry[0], entry[1], quoted)), type, null);
|
||||
values.map(e => new LiteralMapEntry(e.key, e.value, e.quoted)), type, null);
|
||||
}
|
||||
|
||||
export function not(expr: Expression, sourceSpan?: ParseSourceSpan | null): NotExpr {
|
||||
|
@ -311,9 +311,8 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
|
||||
return this.visitAllExpressions(ast.entries, ctx);
|
||||
}
|
||||
visitLiteralMapExpr(ast: o.LiteralMapExpr, ctx: _ExecutionContext): any {
|
||||
const result = {};
|
||||
ast.entries.forEach(
|
||||
(entry) => (result as any)[entry.key] = entry.value.visitExpression(this, ctx));
|
||||
const result: {[k: string]: any} = {};
|
||||
ast.entries.forEach(entry => result[entry.key] = entry.value.visitExpression(this, ctx));
|
||||
return result;
|
||||
}
|
||||
visitCommaExpr(ast: o.CommaExpr, context: any): any {
|
||||
|
@ -50,7 +50,7 @@ class JitEmitterVisitor extends AbstractJsEmitterVisitor {
|
||||
|
||||
createReturnStmt(ctx: EmitterVisitorContext) {
|
||||
const stmt = new o.ReturnStatement(new o.LiteralMapExpr(this._evalExportedVars.map(
|
||||
resultVar => new o.LiteralMapEntry(resultVar, o.variable(resultVar)))));
|
||||
resultVar => new o.LiteralMapEntry(resultVar, o.variable(resultVar), false))));
|
||||
stmt.visitStatement(this, ctx);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user