Polymer / polymer-starter-kit

A starting point for Polymer apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I would say it is bad practice to make shadow DOM for all view ?

codeimmortal opened this issue · comments

Why you are using shadow DOM for rendering view ?

You don't thing it is the bad practice to make shadow DOM . In this way you will have to make seperate css in each view if they use common css .

app

WHY?

Actual use case of shadow dom is this .

Shadow DOM removes the brittleness of building web apps. The brittleness comes from the global nature of HTML, CSS, and JS. Over the years we've invented an exorbitant number of tools to circumvent the issues. For example, when you use a new HTML id/class, there's no telling if it will conflict with an existing name used by the page.

If we have many view each are not interacting with each other why do we need shadow dom ?

Do you not think this is bad practice ?

You can use Shadow DOM for views to make sure that the styles you define in 1 view does not clutter with another view. E.g. if you define a section { background-color: red; } in view 1, you don't want view 2 to break with all it's sections. If you want to share CSS between them, the options are CSS variables or the upcoming part/theme proposal (http://tabatkins.github.io/specs/css-shadow-parts/)

As always, in your application you might opt to not use Shadow DOM for your views, if you desire so. However, for new developers the effect of "CSS taint" can be surprising if you are thinking in terms of components. Therefore we advise to use Shadow DOM to prevent these easy-to-make mistakes, but you are free not to use it.