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
@ -18,7 +18,16 @@ export function pureArrayDef(argCount: number): NodeDef {
|
||||
return _pureExpressionDef(NodeFlags.TypePureArray, new Array(argCount));
|
||||
}
|
||||
|
||||
export function pureObjectDef(propertyNames: string[]): NodeDef {
|
||||
export function pureObjectDef(propToIndex: {[p: string]: number}): NodeDef {
|
||||
const keys = Object.keys(propToIndex);
|
||||
const nbKeys = keys.length;
|
||||
const propertyNames = new Array(nbKeys);
|
||||
for (let i = 0; i < nbKeys; i++) {
|
||||
const key = keys[i];
|
||||
const index = propToIndex[key];
|
||||
propertyNames[index] = key;
|
||||
}
|
||||
|
||||
return _pureExpressionDef(NodeFlags.TypePureObject, propertyNames);
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injector, PipeTransform, RenderComponentType, RootRenderer, Sanitizer, SecurityContext, ViewEncapsulation, WrappedValue} from '@angular/core';
|
||||
import {ArgumentType, NodeDef, NodeFlags, RootData, Services, ViewData, ViewDefinition, ViewFlags, ViewHandleEventFn, ViewUpdateFn, anchorDef, asProviderData, asPureExpressionData, directiveDef, elementDef, nodeValue, pipeDef, pureArrayDef, pureObjectDef, purePipeDef, rootRenderNodes, textDef, viewDef} from '@angular/core/src/view/index';
|
||||
import {inject} from '@angular/core/testing';
|
||||
import {PipeTransform} from '@angular/core';
|
||||
import {NodeDef, NodeFlags, Services, ViewData, ViewDefinition, ViewFlags, ViewUpdateFn, asProviderData, directiveDef, elementDef, nodeValue, pipeDef, pureArrayDef, pureObjectDef, purePipeDef, rootRenderNodes, viewDef} from '@angular/core/src/view/index';
|
||||
|
||||
import {ARG_TYPE_VALUES, checkNodeInlineOrDynamic, createRootView} from './helper';
|
||||
|
||||
@ -38,8 +37,9 @@ export function main() {
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'), pureArrayDef(2),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']})
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'),
|
||||
pureArrayDef(2),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']}),
|
||||
],
|
||||
(check, view) => {
|
||||
const pureValue = checkNodeInlineOrDynamic(check, view, 1, inlineDynamic, values);
|
||||
@ -75,7 +75,7 @@ export function main() {
|
||||
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'), pureObjectDef(['a', 'b']),
|
||||
elementDef(NodeFlags.None, null !, null !, 2, 'span'), pureObjectDef({a: 0, b: 1}),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']})
|
||||
],
|
||||
(check, view) => {
|
||||
@ -116,8 +116,9 @@ export function main() {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
|
||||
[
|
||||
elementDef(NodeFlags.None, null !, null !, 3, 'span'),
|
||||
pipeDef(NodeFlags.None, SomePipe, []), purePipeDef(2),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']})
|
||||
pipeDef(NodeFlags.None, SomePipe, []),
|
||||
purePipeDef(2),
|
||||
directiveDef(NodeFlags.None, null !, 0, Service, [], {data: [0, 'data']}),
|
||||
],
|
||||
(check, view) => {
|
||||
const pureValue = checkNodeInlineOrDynamic(
|
||||
|
Reference in New Issue
Block a user