angular2-hot-loader icon indicating copy to clipboard operation
angular2-hot-loader copied to clipboard

Feature: Add possibility to change ViewEncapsulation mode

Open frederikschubert opened this issue 10 years ago • 0 comments

When adding the encapsulation property to the ComponentMetadata (for example with ViewEncapsulation.None the styles are reloaded correctly. However when changing the mode after that the styles don't change. ~~I think this can be fixed in updateMetadata(component) but I am not sure why the current approach doesn't work.~~ This one is actually caused by Angular and I am not sure i this can be solved. When Angular discovers a component with encapsulation set to Emulated or None it appends the styles of the component as styles to the <head></head> section. So when we reload the component the styles are added again but are not removed. This then looks something like this:

<style>*[_ngcontent-bil-9] {
        color:red;
}</style>
<style>*[_ngcontent-bil-44] {
    color:red;
}</style>

Because Angular discovers the style-tag that has already been set, it changes the selector that emulates the shadow DOM in some random way. I don't know if it would be too much of an effort to implement this feature, but maybe I haven`t fully understood the problem so I am leaving this issue up. This is not an important feature, just something that came to my mind when playing around with the hot-loader.

frederikschubert avatar Dec 18 '15 22:12 frederikschubert