Title: Media queries treat unknown and deprecated media types as `all` (`@media tv` matches, `not tv` does not) · Issue #11643 · NativeScript/NativeScript · GitHub
Open Graph Title: Media queries treat unknown and deprecated media types as `all` (`@media tv` matches, `not tv` does not) · Issue #11643 · NativeScript/NativeScript
X Title: Media queries treat unknown and deprecated media types as `all` (`@media tv` matches, `not tv` does not) · Issue #11643 · NativeScript/NativeScript
Description: Issue Description Runtime bug in @nativescript/core CSS media query parsing (packages/core/css-mediaquery/index.ts, line 138): type: MediaQueryType[type ? type.toLowerCase() : 'all'] ?? 'all', Because MediaQueryType only contains all, pr...
Open Graph Description: Issue Description Runtime bug in @nativescript/core CSS media query parsing (packages/core/css-mediaquery/index.ts, line 138): type: MediaQueryType[type ? type.toLowerCase() : 'all'] ?? 'all', Beca...
X Description: Issue Description Runtime bug in @nativescript/core CSS media query parsing (packages/core/css-mediaquery/index.ts, line 138): type: MediaQueryType[type ? type.toLowerCase() : 'all'] ?? ...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/11643
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Media queries treat unknown and deprecated media types as `all` (`@media tv` matches, `not tv` does not)","articleBody":"### Issue Description\n\nRuntime bug in `@nativescript/core` CSS media query parsing (`packages/core/css-mediaquery/index.ts`, line 138):\n\n```ts\ntype: MediaQueryType[type ? type.toLowerCase() : 'all'] ?? 'all',\n```\n\nBecause `MediaQueryType` only contains `all`, `print`, and `screen`, any other media type (`tv`, `speech`, `handheld`, `projection`, or an unknown identifier) falls back to `'all'` instead of remaining distinct from `'screen'`. Since `checkIfMediaQueryMatches` evaluates queries with `type: MediaQueryType.screen`, `@media tv { ... }` and `@media speech { ... }` rules are applied on every screen, `matchMedia('tv').matches` returns `true`, and `@media not tv { ... }` / `matchMedia('not tv').matches` evaluate to `false`.\n\nPer [Media Queries Level 4 section 2.3 and section 3.2](https://www.w3.org/TR/mediaqueries-4/#media-types) (and in browsers and upstream `ericf/css-mediaquery`), deprecated and unknown media types never match, and negating them with `not` evaluates to `true`.\n\n### Reproduction\n\nSave as `packages/core/css-mediaquery/repro.spec.ts` and run `npx nx run core:test -t 'unknown and deprecated media types'`:\n\n```ts\nimport { matchQuery, MediaQueryType } from '.';\nimport { matchMedia } from '../media-query-list';\nimport { parse } from '../css';\nimport { StyleSheetSelectorScope } from '../ui/styling/css-selector';\nimport { _populateRules } from '../ui/styling/style-scope';\n\ndescribe('unknown and deprecated media types', () => {\n\tit('repro', () => {\n\t\tconst screen = { type: MediaQueryType.screen, width: 400, height: 800, orientation: 'portrait' };\n\t\tconsole.log('matchQuery tv:', matchQuery('tv', screen));\n\t\tconsole.log('matchQuery speech:', matchQuery('speech', screen));\n\t\tconsole.log('matchQuery tv and portrait:', matchQuery('tv and (orientation: portrait)', screen));\n\t\tconsole.log('matchQuery not tv:', matchQuery('not tv', screen));\n\t\tconsole.log('matchQuery print:', matchQuery('print', screen));\n\t\tconsole.log('matchMedia tv:', matchMedia('tv').matches);\n\t\tconsole.log('matchMedia not tv:', matchMedia('not tv').matches);\n\n\t\tconst ast = parse(`\n\t\t\t@media tv { button { color: red; } }\n\t\t\t@media speech { button { color: orange; } }\n\t\t\t@media not tv { button { color: green; } }\n\t\t\t@media print { button { color: blue; } }\n\t\t`);\n\t\tconst rulesets = [];\n\t\t_populateRules(ast.stylesheet.rules, rulesets, []);\n\t\tconst matched = new StyleSheetSelectorScope(rulesets)\n\t\t\t.query({ cssType: 'button' })\n\t\t\t.selectors.map((s) => s.ruleset.declarations[0].value);\n\t\tconsole.log('@media matched colors:', matched);\n\t});\n});\n```\n\nExpected output:\n\n```text\nmatchQuery tv: false\nmatchQuery speech: false\nmatchQuery tv and portrait: false\nmatchQuery not tv: true\nmatchQuery print: false\nmatchMedia tv: false\nmatchMedia not tv: true\n@media matched colors: [ 'green' ]\n```\n\n### Relevant log output (if applicable)\n\n```shell\nmatchQuery tv: true\nmatchQuery speech: true\nmatchQuery tv and portrait: true\nmatchQuery not tv: false\nmatchQuery print: false\nmatchMedia tv: true\nmatchMedia not tv: false\n@media matched colors: [ 'red', 'orange' ]\n```\n\n### Environment\n\n- `@nativescript/core`: `9.1.4` (npm latest) and `main` (`2a41eb1`)\n- Node.js: `v26.13.0`\n- Platform-independent (shared `@nativescript/core` styling and `matchMedia` code)\n\n### Please accept these terms\n\n- [x] I have searched the [existing issues](https://github.com/NativeScript/NativeScript/issues) as well as [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) and this has not been posted before\n- [x] This is a bug report\n- [x] I agree to follow this project's [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc)\n\nCredit: https://ucsbplse.github.io/\n","author":{"url":"https://github.com/trackoor","@type":"Person","name":"trackoor"},"datePublished":"2026-11-14T19:26:38Z","url":"https://github.com/NativeScript/NativeScript/issues/11643"}
| 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:251ab8e7-120c-102e-3d86-c5c81fbf8a94 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D4FC:19F84C:18DC026:1FB65D5:6B012FCF |
| html-safe-nonce | 059c8e1584691c332fc578d24f6aee7dc8e1aa8e034cac6af2960adcde3209a8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEZDOjE5Rjg0QzoxOERDMDI2OjFGQjY1RDU6NkIwMTJGQ0YiLCJ2aXNpdG9yX2lkIjoiMzA4NDQwNzczNTgwMjk5ODczNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c9245855322a471f98be9e62844fee089147d3513051ae302d52d3de5d522c35 |
| hovercard-subject-tag | issue:6394926819 |
| 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/11643/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c89bdfa72b18eb06c8752de42d9bf5f4d99e1b0389725c8563f4c8df57259d5f/NativeScript/NativeScript/issues/11643 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c89bdfa72b18eb06c8752de42d9bf5f4d99e1b0389725c8563f4c8df57259d5f/NativeScript/NativeScript/issues/11643 |
| og:image:alt | Issue Description Runtime bug in @nativescript/core CSS media query parsing (packages/core/css-mediaquery/index.ts, line 138): type: MediaQueryType[type ? type.toLowerCase() : 'all'] ?? 'all', Beca... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trackoor |
| 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