All components should use ViewEncapsulation.None by default
See original GitHub issueAll components should use ViewEncapsulation.None
Expected Behavior
Output HTML should not show _ngcontent-*
etc attributes since they will not be utilized.
Current Behavior
Currently, all but two use default ViewEncapsulation.Emulated
, which adds unnecessary markup to the outputted html. Since this framework is a wrapper for Materalize css framework, there is no reason to use view encapsulation since it already uses global styles. This will the output HTML very clean and easy to reason about.
I will be happy to do a PR if you approve this. If disapprove, please explain logic as to why.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:11 (5 by maintainers)
Top Results From Across the Web
When and why should we use View Encapsulation in angular
None : If we don't want to have any encapsulation at all, we can use ViewEncapsulation.None . If we don't encapsulate anything, the...
Read more >View encapsulation - Angular
When using the emulated view encapsulation, Angular pre-processes all the component's styles so that they are only applied to the component's view.
Read more >Understanding Angular's ViewEncapsulation
Angular doesn't use the Shadow DOM by default, but rather emulates Shadow DOM behaviour. We can however tell a component how the encapsulation ......
Read more >Understanding Angular View Encapsulation - Telerik
In this post, you will have an introduction to viewing encapsulation in Angular for styling your Angular components. Using Components in Angular.
Read more >ViewEncapsulation.None | Angular - EJ 2 Forums | Syncfusion
All my components use encapsulation Emulated (default), but all samples in Syncfusion documentation use Encapsulation None.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @IAMtheIAM,
This is a good concern, we never thought about setting
ViewEncapsulation.None
as we wanted our component to be scoped like suggested by Angular (default value) but you make a good point saying that Materialize CSS already uses global styling.Of course we wouldn’t want any bad behavior by switching but at first sight the risks seems minimal. Please let us talk about it and we’ll come back to you!
Btw thanks for bringing that up and wanting to help us.
Hi, I want to say that this default value on Angular also cause that such problems : https://stackoverflow.com/questions/44210786/style-not-working-for-innerhtml-in-angular-2-typescript
That the style don’t accessible to injected Elements, and you need to define it on component level.
I don’t big architect, but maybe it causes a little confusing and workaround vs. React that this the way things work, so I will be happy to understand why it’s important to define.
I understand that the concern to conflicts with component’s style. Is this the reason ?