Title: Emulated view encapsulation incorrectly transforms CSS that uses `:is()` or `:where()` · Issue #45686 · angular/angular · GitHub
Open Graph Title: Emulated view encapsulation incorrectly transforms CSS that uses `:is()` or `:where()` · Issue #45686 · angular/angular
X Title: Emulated view encapsulation incorrectly transforms CSS that uses `:is()` or `:where()` · Issue #45686 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? compiler, Don't known / other Is this a regression? No Description When using emulated view encapsulation, component CSS that uses the :is or :where pseudo class selector functions g...
Open Graph Description: Which @angular/* package(s) are the source of the bug? compiler, Don't known / other Is this a regression? No Description When using emulated view encapsulation, component CSS that uses the :is or ...
X Description: Which @angular/* package(s) are the source of the bug? compiler, Don't known / other Is this a regression? No Description When using emulated view encapsulation, component CSS that uses the :is...
Opengraph URL: https://github.com/angular/angular/issues/45686
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Emulated view encapsulation incorrectly transforms CSS that uses `:is()` or `:where()`","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncompiler, Don't known / other\n\n### Is this a regression?\n\nNo\n\n### Description\n\nWhen using emulated view encapsulation, component CSS that uses the `:is` or `:where` pseudo class selector functions gets compiled incorrectly.\r\n\r\n# Example 1\r\n\r\nConsider the following 2 selectors, which differ only in the number of items inside of `:is`:\r\n\r\n```css\r\n:is(.foo) {}\r\n:is(.foo, .bar, .baz) {}\r\n```\r\n\r\nI expected each item in the `:is` selector list to be transformed the same, but the first and last items are treated differently from the middle items. This is the compiled result:\r\n\r\n```css\r\n[_ngcontent-uly-c97]:is(.foo) {}\r\n[_ngcontent-uly-c97]:is(.foo, .bar[_ngcontent-uly-c97], .baz)[_ngcontent-uly-c97] {}\r\n```\r\n\r\n# Example 2\r\n\r\nWhen used before or after `:host`, the number of items *inside* of `:is` unexpectedly affects the presence of an `[_ngcontent]` qualifier *outside* of `:is`. The qualifier is missing for 1 item, but added for >1 item. This component CSS:\r\n\r\n```css\r\n:is(.foo) :host {}\r\n:is(.foo, .bar) :host {}\r\n\r\n:host :is(.foo) {}\r\n:host :is(.foo, .bar) {}\r\n```\r\n\r\nCompiles to:\r\n\r\n```css\r\n:is(.foo) [_nghost-kfp-c134] {}\r\n[_ngcontent-kfp-c134]:is(.foo, .bar) [_nghost-kfp-c134] {}\r\n\r\n[_nghost-kfp-c134] [_ngcontent-kfp-c134]:is(.foo) {}\r\n[_nghost-kfp-c134] [_ngcontent-kfp-c134]:is(.foo, .bar)[_ngcontent-kfp-c134] {}\r\n```\r\n\r\n# Reproduction\r\n\r\nhttps://stackblitz.com/edit/angular-ivy-yc96o6?file=src/app/app.component.css demonstrates a live reproduction of this issue.\r\n\r\nFor my specific use case, I had a selector that looked like`:is(a, b, c) :host`. I was able to work around the problem by rewriting it to either of `:host-context(a, b, c) :host` or `a :host, b :host, c :host` (both compile to the same output). But in general, using `:is` and `:where` seems either unsupported or broken. If it's unsupported, I think it would be helpful if the compiler threw an error because the current behavior is hard to predict and does not seem useful.\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://stackblitz.com/edit/angular-ivy-yc96o6?file=src/app/app.component.css\n\n### Please provide the exception or error you saw\n\n_No response_\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nI'm not using `ng`, so I can't provide `ng version` output. But the reproduction in StackBlitz is using @angular/* packages at version 13.3.3.\n```\n\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/ChrisTM","@type":"Person","name":"ChrisTM"},"datePublished":"2022-04-19T23:11:23Z","url":"https://github.com/angular/angular/issues/45686"}
| 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:70a08e18-ac41-5f42-d945-31ea830d361e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C336:25A204:A28BD0:D8044E:6B00E6DE |
| html-safe-nonce | f516ea0eb5bef78dac31c5ce358a5d43d372ea6f7e17ce979d565810a9848a89 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzM2OjI1QTIwNDpBMjhCRDA6RDgwNDRFOjZCMDBFNkRFIiwidmlzaXRvcl9pZCI6Ijg1MzY5MjY0MDM3ODA3MzI2MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 34707a304e03817e140dd3f94eca04b20c6a04cb46b9ce07516d87c594450546 |
| hovercard-subject-tag | issue:1208956619 |
| 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/45686/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d01a7bf2df15d4197c516d3edd7976daf29634c7ffe764cf8d591d8eca93aee5/angular/angular/issues/45686 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d01a7bf2df15d4197c516d3edd7976daf29634c7ffe764cf8d591d8eca93aee5/angular/angular/issues/45686 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? compiler, Don't known / other Is this a regression? No Description When using emulated view encapsulation, component CSS that uses the :is or ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ChrisTM |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width