Title: CSS styles not applied if using attribute HostBinding and styling a DIV with the direct child selector in a production build · Issue #49100 · angular/angular · GitHub
Open Graph Title: CSS styles not applied if using attribute HostBinding and styling a DIV with the direct child selector in a production build · Issue #49100 · angular/angular
X Title: CSS styles not applied if using attribute HostBinding and styling a DIV with the direct child selector in a production build · Issue #49100 · angular/angular
Description: 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 ha...
Open Graph Description: 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 selec...
X Description: 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 s...
Opengraph URL: https://github.com/angular/angular/issues/49100
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CSS styles not applied if using attribute HostBinding and styling a DIV with the direct child selector in a production build","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\nDon't known / other\r\n\r\n### Is this a regression?\r\n\r\nYes\r\n\r\n### Description\r\n\r\nIf using attribute HostBinding and styling a DIV element with the direct child selector, the styles are not applied.\r\n**This happens only in a producton build.**\r\n\r\nReproduction:\r\n**app.component.html**\r\n```html\r\n\u003cdiv class=\"example-1\">\r\n Example 1 (css: > div)\r\n\u003c/div>\r\n\u003cdiv class=\"example-2\">\r\n Example 2 (css: div)\r\n\u003c/div>\r\n\u003csection class=\"example-3\">\r\n Example 3 (css: > section)\r\n\u003c/section>\r\n\u003csection class=\"example-4\">\r\n Example 4 (css: section)\r\n\u003c/section>\r\n```\r\n**app.component.ts**\r\n```ts\r\nimport {Component, HostBinding} from '@angular/core';\r\n\r\n@Component({\r\n selector: 'app-root',\r\n templateUrl: './app.component.html',\r\n styleUrls: ['./app.component.scss'],\r\n})\r\nexport class AppComponent {\r\n\r\n @HostBinding('attr.data-foo')\r\n public foo = 'bar';\r\n}\r\n\r\n```\r\n**app.component.scss**\r\n```scss\r\n:host {\r\n &[data-foo=\"bar\"] {\r\n > div.example-1 {\r\n background-color: cyan; // not working\r\n }\r\n\r\n div.example-2 {\r\n background-color: yellow; // working\r\n }\r\n\r\n > section.example-3 {\r\n background-color: red; // working\r\n }\r\n\r\n section.example-4 {\r\n background-color: green; // working\r\n }\r\n }\r\n}\r\n\r\n```\r\n\r\n\r\nIn the transpiled CSS we noticed various issues:\r\n\r\nExample 1:\r\n\r\n- \"nghost\" attribute is missing after the attribute selector _[data-foo=bar]_\r\n- \"nghost\" attribute after _div.example-1_ should instead be \"ngcontent\"\r\n\r\nExample 2:\r\n\r\n- \"ngcontent\" attribute is missing after _div.example-2_. **IMPORTANT! This is not the cause of this problem, but causes the styles to leak into child components. Please let me know if I should file a separate issue for this case.**\r\n\r\n\r\n\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\nhttps://github.com/Marcarrian/angular-15-attribute-host-binding-issue\r\n\r\n### Please provide the exception or error you saw\r\n\r\n_No response_\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nAngular CLI: 15.1.5 \r\nNode: 16.16.0 \r\nPackage Manager: npm 8.11.0\r\nOS: win32 x64 \r\n \r\nAngular: 15.1.4 \r\n... animations, common, compiler, compiler-cli, core, forms\r\n... platform-browser, platform-browser-dynamic, router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1501.5\r\n@angular-devkit/build-angular 15.1.5\r\n@angular-devkit/core 15.1.5\r\n@angular-devkit/schematics 15.1.5\r\n@angular/cli 15.1.5\r\n@schematics/angular 15.1.5\r\nrxjs 7.8.0\r\ntypescript 4.9.5\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\n_No response_","author":{"url":"https://github.com/Marcarrian","@type":"Person","name":"Marcarrian"},"datePublished":"2023-02-16T08:35:20Z","url":"https://github.com/angular/angular/issues/49100"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cdec2960-0153-ef7f-38ac-84ba8d10ba4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9FA:3D4705:886D84:B17D99:6B00DAEE |
| html-safe-nonce | ee471da99d98d8e78f0f13ed34c2cfc66ed1c63a11ecb8b29f50ca5739c6ef24 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUZBOjNENDcwNTo4ODZEODQ6QjE3RDk5OjZCMDBEQUVFIiwidmlzaXRvcl9pZCI6IjgxNTE4NzkyMDk4NTAwMzQ5MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 217e3e268f8c5982e1eb82437ed52c892083baeb68bcbc8bbab2eaaa2abf968a |
| hovercard-subject-tag | issue:1587257274 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/49100/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80df998899181353780dbb4902bad95672deaa04aeb2b1879e7b9b91b452040c/angular/angular/issues/49100 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80df998899181353780dbb4902bad95672deaa04aeb2b1879e7b9b91b452040c/angular/angular/issues/49100 |
| og:image:alt | 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 selec... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Marcarrian |
| hostname | github.com |
| expected-hostname | github.com |
| None | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width