Components: docs: clarify that ViewEncapsulation.Native is not supported

Created on 2 Mar 2017  路  11Comments  路  Source: angular/components

Bug, feature request, or proposal:

Feature request.

What is the expected behavior?

ViewEncapsulation.Native (shadow DOM) is supported.

What is the current behavior?

Not supported as of beta2.

What are the steps to reproduce?

https://plnkr.co/edit/cYf5hUx1GLXrMLSCg4ci?p=preview
Change the ViewEncapsulation between Native and Emulated.
Native (Shadow DOM) doesn't work with material beta2.

What is the use-case or motivation for changing an existing behavior?

Support shadow DOM.

Which versions of Angular, Material, OS, browsers are affected?

"@angular/common": "4.0.0-rc.1",
"@angular/compiler": "4.0.0-rc.1",
"@angular/core": "4.0.0-rc.1",
"@angular/flex-layout": "2.0.0-rc.1",
"@angular/forms": "4.0.0-rc.1",
"@angular/http": "4.0.0-rc.1",
"@angular/material": "2.0.0-beta.2",
Chrome on Win10.

Is there anything else we should know?

Nope.

P3 many material.angular.io docs elements feature help wanted

Most helpful comment

Also ViewEncapsulation.ShadowDom (v1 spec) kills Angular Material. Even if the Material css is global. It would be really nice to see some clear documentation about this.

All 11 comments

This would be fantastic and well placed in the web component future.

Can this be bumped up in priority? We have widgets that are being used by third parties and we are running into css bleeding into the components on certain sites. And we are having to deal with them individually. Would be fantastic and save us a lot of headaches if ViewEncapsulation.Native will be supported soon.

Since this was lacking an official comment:

We don't currently support ViewEncapsulation.Native because our theming requires global styles. Once we are able to use css custom properties (i.e. not support IE11), then we will make the switch.

Code splitting does not work at all for Angular Material's CSS due to this issue, and the initial HTML response of an universal app become so huge when one include Angular Material into the app.

Isn't it possible using some other strategy for theming?
For example, sass-loader accepts variables passed from webpack.config.

@kimamula see https://material.angular.io/guide/theming#theming-only-certain-components

You can manually create a CSS file that includes only the styles you need for an SSR page.

@jelbourn Thanks.
Is it possible to apply theme to lazily loaded Angular Material components without including their CSS into the initial page response?

You'd have to load the theme file at the same time as the component or else you'd see a flash of unstyled content

Thanks, it seems working.
But if Angular Material stops depending on global CSS, I don't have to manage the code splitting myself.

I am sorry that this may be a little bit off topic, though.

Also ViewEncapsulation.ShadowDom (v1 spec) kills Angular Material. Even if the Material css is global. It would be really nice to see some clear documentation about this.

I agree that this should be documented in the Getting Started Guide or another commonly read location.

Note that there is already an open issue tracking the need to document this for ViewEncapsulation.ShadowDom.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hiblton picture Hiblton  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments

LoganDupont picture LoganDupont  路  3Comments

Miiekeee picture Miiekeee  路  3Comments

savaryt picture savaryt  路  3Comments