New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ViewEncapsulation.None styles bleed into ViewEncapsulation.Native components when siblings #5059
Comments
Right now Angular is doing this so a user can mix and match components with On Sun, Nov 1, 2015 at 8:03 PM Jeremy Wilken notifications@github.com
|
That is interesting, but as a counterpoint wouldn't that also potentially cause issues with the Native mode? If I'm using a third party component that is None and it uses the same CSS selector, it would get injected into my component. I certainly didn't expect sibling style rules to get injected into the shadow root of the Native mode component. I can at least see a case for more granular control over if this occurs or not, perhaps with a StrictNative mode. Also, since styles inside of the Emulated components are given unique attributes, they won't ever apply to another component, so what is the reason to inject them? |
No longer the case, see http://plnkr.co/edit/XDIJ1YOz4W3uI9t75Jg4?p=preview |
Still the case in fact, cf plnkr above |
@tbosch Re: your comment above: I'm now using angular 6.x, fwiw. |
@gnomeontherun Is the issue relevant? |
Depends on what you mean by relevant. I found this a while back with my investigations of encapsulation modes and believe this is at least not documented still today. I would have called this a bug, but there are reasons it could make sense, but basically anytime you mix modes you're probably playing with 🔥 I've not run into this issue with real world scenarios, but that is because I don't mix modes. |
@gnomeontherun Since your demo does not work: I have update for Angular 6 @mhevery The problem is really urgent! Is this solved through Ivy? |
Looks like the plunkr broke sometime in the past few years, but I think this is still a problem. It is at least not what I would expect, as Native should shield you from external styles, where this explicitly injects them from sibling components. |
I'm experiencing a similar issue, asked here https://stackoverflow.com/questions/53129175/viewencapsulation-emulated-styles-are-copied-into-shadow-root-by-a-viewencapsul. I've also got a simple reproduction here https://github.com/collinstevens/angular-encapsulation. |
@tbosch wrote:
As far as I can tell we have a thing called a This doesn't seem right to me. Instead, I believe that we should create a new |
This is still the case with ViewEncapsulation.Shadowdom which is very bad imho. First, it creates huge overhead inserting all that styles, but even more concerning, you can not depend on the correct rendering of your components because there are styles injected which you explicitly not want in it. That is the whole point of shadow dom, right? |
Right. I believe the solution is what I wrote here #5059 (comment) |
@petebacondarwin would it be possible to currently use your approch? like overwriting the SharedStylesHost ? |
I am not sure. The |
Too bad, thank you :) |
When there are sibling components, one with ViewEncapsulation.Native and the other with ViewEncapsulation.None, the styles that any component stylings are being appended to the shadow root of the one component set to Native.
Plunker: http://plnkr.co/edit/huN8xe0S7xH5CUw4B2P6?p=previewUpdated Stackblitz: https://stackblitz.com/edit/angular-issue-5059?file=src/app/app.component.html
A component set to Native should not adopt the rest of the CSS rules from non-Native components. In the screenshot of the rendered DOM, the last three style elements are appended to the end of the shadow root, but they are actually declared in the other two components which are set to None and Emulated modes.
If all three components are set to Native, then the rules are applied only to the local component, but when they are mixed the rules bleed over into Native (but don't bleed out of Native).
The text was updated successfully, but these errors were encountered: