fix(ivy): set encapsulation metadata (#27115)

PR Close #27115
This commit is contained in:
Olivier Combe 2018-11-15 16:00:55 +01:00 committed by Misko Hevery
parent 60800da6c1
commit 91bffa9c53
2 changed files with 12 additions and 1 deletions

View File

@ -94,7 +94,13 @@ describe('compiler compliance: styling', () => {
} }
}; };
const template = 'div.cool { color: blue; }", ":host.nice p { color: gold; }'; const template = `
MyComponent.ngComponentDef = $r3$.ɵdefineComponent({
styles: ["div.cool { color: blue; }", ":host.nice p { color: gold; }"],
encapsulation: 1
})
`;
const result = compile(files, angularFiles); const result = compile(files, angularFiles);
expectEmit(result.source, template, 'Incorrect template'); expectEmit(result.source, template, 'Incorrect template');
}); });

View File

@ -269,6 +269,11 @@ export function compileComponentFromMetadata(
definitionMap.set('styles', o.literalArr(strings)); definitionMap.set('styles', o.literalArr(strings));
} }
// Only set view encapsulation if it's not the default value
if (meta.encapsulation !== null && meta.encapsulation !== core.ViewEncapsulation.Emulated) {
definitionMap.set('encapsulation', o.literal(meta.encapsulation));
}
// e.g. `animations: [trigger('123', [])]` // e.g. `animations: [trigger('123', [])]`
if (meta.animations !== null) { if (meta.animations !== null) {
definitionMap.set( definitionMap.set(