Skip to content

Commit 8488e03

Browse files
committed
fix(renderer): add styles when ViewEncapsulation is None
fixes #794
1 parent 354074d commit 8488e03

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: nativescript-angular/renderer.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ export class NativeScriptRendererFactory implements RendererFactory2 {
5858
return renderer;
5959
}
6060

61-
if (type.encapsulation === ViewEncapsulation.Emulated) {
61+
if (type.encapsulation === ViewEncapsulation.None) {
62+
type.styles.map(s => s.toString()).forEach(addStyleToCss);
63+
renderer = this.defaultRenderer;
64+
} else {
6265
renderer = new EmulatedRenderer(type, this.rootNgView, this.zone, this.viewUtil);
6366
(<EmulatedRenderer>renderer).applyToHost(element);
64-
} else {
65-
renderer = this.defaultRenderer;
6667
}
6768

6869
this.componentRenderers.set(type.id, renderer);
@@ -253,9 +254,12 @@ class EmulatedRenderer extends NativeScriptRenderer {
253254
private addStyles(styles: (string | any[])[], componentId: string) {
254255
styles.map(s => s.toString())
255256
.map(s => replaceNgAttribute(s, componentId))
256-
.forEach(addCss);
257+
.forEach(addStyleToCss);
257258
}
259+
}
258260

261+
function addStyleToCss(style: string): void {
262+
addCss(style);
259263
}
260264

261265
function replaceNgAttribute(input: string, componentId: string): string {

0 commit comments

Comments
 (0)