Title: feat(core): apply CSS cascade layer (@layer) rules · Issue #11461 · NativeScript/NativeScript · GitHub
Open Graph Title: feat(core): apply CSS cascade layer (@layer) rules · Issue #11461 · NativeScript/NativeScript
X Title: feat(core): apply CSS cascade layer (@layer) rules · Issue #11461 · NativeScript/NativeScript
Description: Current behavior _populateRules in ui/styling/style-scope.ts only descends into @media at-rules. Any other block at-rule — @layer, @supports, @scope, @container — is silently dropped with its contents. @layer utilities { .my-util { color...
Open Graph Description: Current behavior _populateRules in ui/styling/style-scope.ts only descends into @media at-rules. Any other block at-rule — @layer, @supports, @scope, @container — is silently dropped with its conte...
X Description: Current behavior _populateRules in ui/styling/style-scope.ts only descends into @media at-rules. Any other block at-rule — @layer, @supports, @scope, @container — is silently dropped with its conte...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/11461
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(core): apply CSS cascade layer (@layer) rules","articleBody":"## Current behavior\n\n`_populateRules` in `ui/styling/style-scope.ts` only descends into `@media` at-rules. Any other block at-rule — `@layer`, `@supports`, `@scope`, `@container` — is silently dropped **with its contents**.\n\n```css\n@layer utilities {\n\t.my-util { color: red; }\n}\n```\n\n`.my-util` never applies. This is already biting the ecosystem: Tailwind v4 output crashes/loops on `@layer` (NativeScript/tailwind#197), and Panda CSS / Bamboo / UnoCSS all emit cascade layers, so none of the modern build-time atomic-CSS pipelines can feed NativeScript today. Community workarounds flatten `@layer` at bundler time (e.g. ns-tailwind-vite), which loses the cascade semantics.\n\n## Proposal\n\nApply `@layer` per CSS Cascade Level 5, scoped to what NativeScript's cascade implements:\n\n- **Parse**: the css-tree adapter (`css/css-tree-parser.ts`) already emits `{type: 'layer', rules: [...]}` — it just needs to keep the prelude (layer names).\n- **Order**: a document-wide name → ordinal registry; statement form `@layer a, b;` pre-declares order, block form registers on first sight, dotted names (`a.b`) resolve through ancestors, anonymous blocks get unreferenceable names.\n- **Cascade**: each `RuleSet` carries a `layerPath: number[]`; `compareSelectors` compares layer paths *before* specificity, with unlayered rules sorting after all layered ones — matching the spec (unlayered author styles beat all layered styles; layer order beats specificity within layers).\n- **`@import \"x.css\" layer(name)`** nests the imported sheet under the named layer.\n\nDeliberately out of scope: `!important` layer-order reversal (NS does not implement `!important` — it warns and strips) and other block at-rules (`@supports`, `@container`, `@scope`), which still need real semantics and are safer left dropped than applied unconditionally.\n\n## PR\n\nI have a patch ready on a fork branch with unit tests — will open the PR referencing this issue.","author":{"url":"https://github.com/aleclarson","@type":"Person","name":"aleclarson"},"datePublished":"2026-09-28T04:23:27Z","url":"https://github.com/NativeScript/NativeScript/issues/11461"}
| 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:b1d69711-3d4a-9cc8-ff5d-abb878fd7871 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF84:2564F:168A818:1DB038A:6B012FD3 |
| html-safe-nonce | 161bfb0ecdd92981fee57b674e288cf64adb7df1aacb95c4e810362e512c0716 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjg0OjI1NjRGOjE2OEE4MTg6MURCMDM4QTo2QjAxMkZEMyIsInZpc2l0b3JfaWQiOiI2NzQwNTY1MTcxMjcxNDQ2NDgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 67cb8b4e82981c8d0362164b39c1d4e9b774254651754c090b1c43d168033779 |
| hovercard-subject-tag | issue:5609280445 |
| 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/NativeScript/NativeScript/11461/issue_layout |
| twitter:image | https://opengraph.githubassets.com/98d3ed2bff83307c6ec8b98fe5cb6d6fd9241cd224d8e7bc2789cb836c1b0e6f/NativeScript/NativeScript/issues/11461 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/98d3ed2bff83307c6ec8b98fe5cb6d6fd9241cd224d8e7bc2789cb836c1b0e6f/NativeScript/NativeScript/issues/11461 |
| og:image:alt | Current behavior _populateRules in ui/styling/style-scope.ts only descends into @media at-rules. Any other block at-rule — @layer, @supports, @scope, @container — is silently dropped with its conte... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aleclarson |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width