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
CSS styles not applied if using attribute HostBinding and styling a DIV with the direct child selector in a production build #49100
Comments
Since Angular 15, Angular incorrectly transpiles SCSS to CSS in the following constellation: - Attribute HostBinding (@HostBinding('attr.data-foo')) - Styling DIV using direct child selector - Production build Example: ```scss :host[data-foo="bar"] > div { background-color: cyan; // not working } ``` We have reported this issue to Angular angular/angular#49100
Since Angular 15, Angular incorrectly transpiles SCSS to CSS in the following constellation: - Attribute HostBinding (@HostBinding('attr.data-foo')) - Styling DIV using direct child selector - Production build Example: ```scss :host[data-foo="bar"] > div { background-color: cyan; // not working } ``` We have reported this issue to Angular angular/angular#49100
Since Angular 15, Angular incorrectly transpiles SCSS to CSS in the following constellation: - Attribute HostBinding (@HostBinding('attr.data-foo')) - Styling DIV using direct child selector - Production build Example: ```scss :host[data-foo="bar"] > div { background-color: cyan; // not working } ``` We have reported this issue to Angular angular/angular#49100
I looks like that it was a regression introduced in 15.1.2. I suspect my fix #48558 to be the cause. I will look into it. Thanks for the report 👍 |
Since Angular 15, Angular incorrectly transpiles SCSS to CSS in the following constellation: - Attribute HostBinding (@HostBinding('attr.data-foo')) - Styling DIV using direct child selector - Production build Example: ```scss :host[data-foo="bar"] > div { background-color: cyan; // not working } ``` We have reported this issue to Angular angular/angular#49100
@dario-piotrowicz. It definitely looks like my change is at the root of this issue (any hex character after the In Any idea why ? |
@JeanMeche I'm not too sure, but if the test is valid I suspect that that's not the text that the have you tried that? |
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
Thanks for the heads up. Just found the difference: Selectors had no space on prod builds ! I've opened #49118 for review |
Hey @JeanMeche, thank you for the analysis and the potential fix. We worked around this issue by using the CSS "is" selector: :host {
&:is([data-foo="bar"]) {
> div.example-5 {
background-color: lightskyblue; // working in dev and prod build
}
}
} In the constellation of using two attribute selectors, we noticed a similar issue. This time, the styles are applied only in a production build. :host {
&:is([data-foo="bar"], [data-foo-2="bar-2"]) {
> div.example-6 {
background-color: violet; // ONLY working in prod build
}
}
} Please let me know if I should file a separate issue or if this is sufficient. I have updated my reproduction repository with examples 5 and 6. |
Nice finding, Could you open a separate issue ? It wasn't working even before the regression was introduced ! |
I have created a separate issue #49157 |
any update on the fix for this issue? We're affected by it as well. |
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100
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. |
…ar#49118) In prod builds, selectors are optimized and spaces a removed. angular#48558 introduced a regression on selectors without spaces. This commit fixes tihs. Fixes angular#49100 PR Close angular#49118
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
If using attribute HostBinding and styling a DIV element with the direct child selector, the styles are not applied.
This happens only in a producton build.
Reproduction:
app.component.html
app.component.ts
app.component.scss
In the transpiled CSS we noticed various issues:
Example 1:
Example 2:
Please provide a link to a minimal reproduction of the bug
https://github.com/Marcarrian/angular-15-attribute-host-binding-issue
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: