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
Combining :host-context and :host-context doesn't work #19199
Comments
Would |
That appears to work in my example, although I wouldn't expect it to. The resulting CSS is: .some-theme[_nghost-c6] .large-viewport[_ngcontent-c6],
.some-theme .large-viewport [_nghost-c6] {
/* theme "some" is enabled and we're in a large viewport */
} The second part of the selector makes this work in my case. It only works because both Also note that |
Note that there's kind of a workaround: selector parts before .some-theme.large-viewport :host-context {
// host when theme "some" is enabled and we're in a large viewport
} becomes .some-theme.large-viewport [_nghost-c6] {
// host when theme "some" is enabled and we're in a large viewport
} Ergo, if we know the relative location of the ancestors matching If we don't know the relative location of the ancestors matching these two selectors, we need a more complicated selector to match all possible cases: .some-theme .large-viewport :host-context,
.some-theme :host-context.large-viewport, // <-- can't use :host, only :host-context;
// and note there's a difference between
// :host-context.foo and :host-context(.foo)
:host-context(.some-theme.large-viewport),
.large-viewport .some-theme :host-context,
.large-viewport :host-context.some-theme {
// host when theme "some" is enabled and we're in a large viewport
} which yields the selector we need to fully get |
There is the same kind of problem when combining css : :host-context(.parent):host(.host) .child {
display: block;
} output : .parent[_nghost-c6] -no-combinator.host[_nghost-c6] .child[_ngcontent-c6], .parent [_nghost-c6] -no-combinator.host[_nghost-c6] .child[_ngcontent-c6] {
display: block;
} I solved this issue using @bgotink 's hack |
Fix an error when use two or more :host-context selector. Now all host-context generate all posible combinations in the css result. Close issue angular#19199
Fix an error when use two or more :host-context selector. Now all host-context generate all posible combinations in the css result. Close issue angular#19199
Fix an error when use two or more :host-context selector. Now all host-context generate all posible combinations in the css result. Close issue angular#19199
Fix an error when use two or more :host-context selector. Now all host-context generate all posible combinations in the css result. Close issue angular#19199
I encountered the issue with combining CSS selectors inside :host-context() only when using AOT build with CLI > 1.6.3 @bgotink comment solved my issue also in AOT build with CLI 1.7.3 - Thanks!!! so instead of |
same problem.i only use |
Same problem here. Strugling for hours without any result with :host and/or :host-context. |
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
I created a new PR that I believe fixes this correctly. See #40494 |
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes #19199 PR Close #40494
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes angular#19199
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes #19199 PR Close #40494
In `ViewEncapsulation.Emulated` mode, the compiler must generate additional combinations of selectors to handle the `:host-context()` pseudo-class function. Previously, when there is was more than one `:host-context()` selector in a rule, the compiler was generating invalid selectors. This commit generates all possible combinations of selectors needed to match the same elements as the native `:host-context()` selector. Fixes #19199 PR Close #40494
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
Combining multiple
:host-context
in a template doesn't work:The resulting CSS is
(newlines added for readability, spacing within the selector was copy pasted verbatim)
Expected behavior
The selector matches the host if any ancestor matches
.some-theme
and any ancestor matches.large-viewport
.The resulting selector could be something along the lines of
Minimal reproduction of the problem with instructions
Here is a plunker that shows the same elements in native web components (v0 and v1) and Angular 4. Modifying the angular version of the plunker shows that this doesn't work as expected in 4.3, 4.4.0-RC.0 or 5.0.0-beta.7.
The native web components v1 part only seems to be styled correctly in Chrome. I'm unable to debug the Shadow DOM in Safari.
What is the motivation / use case for changing the behavior?
The behaviour of the
:host-context
in emulated view encapsulation doesn't match the native:host-context
in Shadow DOM v0 and v1.Environment
The text was updated successfully, but these errors were encountered: