-
Notifications
You must be signed in to change notification settings - Fork 27k
[Documentation] Expand the recommended use of ::ng-deep #65944
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
Conversation
jelbourn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we would want any use-case in which ::ng-deep is recommended. Even in the scenario described in this PR, you're still reaching into encapsulated components and clobbering styles that are likely not intended to be overwritten by their author.
|
Per above. |
|
@jelbourn yes, but I think there may be valid use cases for that, and that it overall doesn't even compare with the behavior of I think a valid use case is when you want a reusable Without saying that it's an Angular superhighway that everyone should use in their project, I think it would be fair not to discourage people to use this tool, in cases (such as this) where its behavior isn't chaotic. Otherwise, I would ask you : if not using |
|
You could either use design tokens like Angular Material does, or consider some css custom properties as part of your public API.
|
|
I found no source in the Angular documentation about "design tokens". I doubt it's as easy to use as Say I go with the custom CSS properties solution. That means that my component, the
That seems to me like a giant bug nest, especially when compared to the simplicity of using
Yes, because this documentation declares it so, but that circles back to the reason why I want that to change. |
Among the possible uses of
::ng-deep, this change specifies two different cases, and declares that the "Angular team's discouragement" on the use of::ng-deepnow only applies to one of these cases.Follows #65718
The two cases are as follows :
::ng-deepat the start of a selector is still discouraged, as it applies style outside of the component, but inconsistently as it only triggers when the component is loaded.::ng-deepin the middle of a selector is now okayed (whether the left part is:hostor something else), as its effects are constrained to the HTML element of the component (and its descendents, whether written in the component's template, in child content, in non-recommended innerHTML bindings...).PR Type
What kind of change does this PR introduce?