fix(ivy): change detection strategy not being passed to compiler (#27753)

Fixes the defined change detection strategy not being passed to the compiler when a component is being compiled.

PR Close #27753
This commit is contained in:
Kristiyan Kostadinov
2018-12-20 09:49:24 +01:00
committed by Matias Niemelä
parent 4b70a4e905
commit a833b98fd0
8 changed files with 83 additions and 72 deletions

View File

@ -251,6 +251,7 @@ export function compileComponentFromMetadata(
const directivesUsed = new Set<o.Expression>();
const pipesUsed = new Set<o.Expression>();
const changeDetection = meta.changeDetection;
const template = meta.template;
const templateBuilder = new TemplateDefinitionBuilder(
@ -313,6 +314,11 @@ export function compileComponentFromMetadata(
'data', o.literalMap([{key: 'animation', value: meta.animations, quoted: false}]));
}
// Only set the change detection flag if it's defined and it's not the default.
if (changeDetection != null && changeDetection !== core.ChangeDetectionStrategy.Default) {
definitionMap.set('changeDetection', o.literal(changeDetection));
}
// On the type side, remove newlines from the selector as it will need to fit into a TypeScript
// string literal, which must be on one line.
const selectorForType = (meta.selector || '').replace(/\n/g, '');