question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All components should use ViewEncapsulation.None by default

See original GitHub issue

All 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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
jfcerecommented, Oct 17, 2017

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.

0reactions
yim222commented, Feb 2, 2020

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 ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found