Skip to content

fix(renderer): add styles when ViewEncapsulation is None #812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions nativescript-angular/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
(<EmulatedRenderer>renderer).applyToHost(element);
} else {
renderer = this.defaultRenderer;
}

this.componentRenderers.set(type.id, renderer);
Expand Down Expand Up @@ -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 {
Expand Down