From 8488e038adb2ab710b9caed87b16cb9436fbe278 Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Mon, 22 May 2017 11:12:32 +0300 Subject: [PATCH] fix(renderer): add styles when ViewEncapsulation is None fixes #794 --- nativescript-angular/renderer.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nativescript-angular/renderer.ts b/nativescript-angular/renderer.ts index 1a9f0bfbc..bfe7033dd 100644 --- a/nativescript-angular/renderer.ts +++ b/nativescript-angular/renderer.ts @@ -58,11 +58,12 @@ export class NativeScriptRendererFactory implements RendererFactory2 { return renderer; } - if (type.encapsulation === ViewEncapsulation.Emulated) { + if (type.encapsulation === ViewEncapsulation.None) { + type.styles.map(s => s.toString()).forEach(addStyleToCss); + renderer = this.defaultRenderer; + } else { renderer = new EmulatedRenderer(type, this.rootNgView, this.zone, this.viewUtil); (renderer).applyToHost(element); - } else { - renderer = this.defaultRenderer; } this.componentRenderers.set(type.id, renderer); @@ -253,9 +254,12 @@ class EmulatedRenderer extends NativeScriptRenderer { private addStyles(styles: (string | any[])[], componentId: string) { styles.map(s => s.toString()) .map(s => replaceNgAttribute(s, componentId)) - .forEach(addCss); + .forEach(addStyleToCss); } +} +function addStyleToCss(style: string): void { + addCss(style); } function replaceNgAttribute(input: string, componentId: string): string {