MOBILE-2915 core: Inject CSS safely

main
Albert Gasset 2019-03-13 10:00:57 +01:00
parent 7383164e36
commit 67dfaada27
1 changed files with 5 additions and 3 deletions

View File

@ -38,10 +38,12 @@ export class CoreStyleComponent implements OnChanges {
* Component being changed. * Component being changed.
*/ */
ngOnChanges(changes: { [name: string]: SimpleChange }): void { ngOnChanges(changes: { [name: string]: SimpleChange }): void {
const css = this.prefixCSS(this.css, this.prefix);
if (this.element && this.element.nativeElement) { if (this.element && this.element.nativeElement) {
this.element.nativeElement.innerHTML = '<style>' + css + '</style>'; const style = document.createElement('style');
style.innerText = this.prefixCSS(this.css, this.prefix);
this.element.nativeElement.innerHTML = '';
this.element.nativeElement.appendChild(style);
} }
} }