I have a very strange issue with a css rule not being applied when injected in html this is the code injecting the html:
decorate(text)
{
return this.sanitizer.bypassSecurityTrustHtml(text.replace('Doe','<b>Doe</b>'));
}
in the template :
<h1 [innerHTML]="decorate('JohnDoe')"></h1>
<h1>Jane<b>Doe</b></h1>
I added a CSS rule for
h1 { color:#888; }
h1 b {color:#ff0000;}
but still, JognDoe is grey while JaneDoe gets the Doe in red as expected. Why is Johns'Doe not rendered in red?
Rendered HTML looks like this in the inspector:
<h1 _ngcontent-c11="">John<b>Doe</b></h1>
<h1 _ngcontent-c11="">Jane<b _ngcontent-c11="">Doe</b></h1>
To me there is no reason for Johndoe to be grey..:
I assembled a small sandbox with the issue :