Repository navigation
feat(core): evaluate @supports conditions instead of dropping their rules - #11592
Draft
edusperoni wants to merge 1 commit into
main from
feat/css-supports
Draft
Conversation
Copy link
Copy Markdown
Contributor
PR Checklist
What is the current behavior?
Both CSS parsers (css-tree, and rework / webpack's css2json) emit @supports blocks, but _populateRules only handles @media, @keyframes and plain rules, so every rule inside an @supports block is silently dropped. A common progressive-enhancement pattern does nothing:
.card { background-color: #e0e0e0; }
@supports (color: color-mix(in srgb, red, blue)) {
.card { background-color: color-mix(in srgb, var(--accent) 20%, white); }
}
What is the new behavior?
@supports conditions are evaluated when the stylesheet is built (ui/styling/css-supports.ts):
(property: value) passes when core knows the property and that property's own value converter accepts the value. (color: color-mix(...)) is true because Color parses color-mix(), while (display: grid) is false. var() / calc() values, CSS-wide keywords and custom properties pass, matching browsers.
selector(...) passes when core's selector parser accepts it.
not / and / or and nested parentheses follow css-conditional-3. Mixing and/or without parentheses, or any other malformed condition, drops the block.
- Unknown properties and unknown functions (
font-tech(), etc.) evaluate to false. That keeps them negatable, so @supports not (display: grid) applies. Unknown or invalid conditions log a Trace warning in the Style category.
A supported block is flattened into the surrounding rule list, so its rules keep their source position and override an earlier fallback by order, inside @media too. @keyframes inside @supports work.
To support the declaration test, properties/index.ts now records each CssProperty value converter by CSS name, updated by overrideHandlers, and exposes _isCssDeclarationSupported. Shorthands and CssAnimationProperty use their existing converters.
Notes:
- Support follows each property's converter. A property whose converter accepts any string reports any value as supported, and a converter that returns
NaN counts as unsupported.
- A property registered by a module that has not loaded yet when the stylesheet is parsed reports as unknown.
feat(core): evaluate @supports conditions instead of dropping their r...
1d26c38
...ules
@supports blocks were parsed but never reached the cascade, so their rules
were silently lost. Conditions are now evaluated when the stylesheet is
built:
- (property: value) passes when core knows the property and its value
converter accepts the value, so (color: color-mix(...)) is true and
(display: grid) is false. var() and calc() values pass.
- selector(...) passes when core parses the selector.
- not / and / or and nested parentheses follow css-conditional-3; unknown
tests and functions evaluate to false (and can be negated), and a
malformed condition drops the block. Both log a Trace warning.
Supported blocks are flattened in place, so their rules keep their source
position and override an earlier fallback by order.
Copy link
Copy Markdown
|
View your CI Pipeline Execution ↗ for commit 1d26c38
| Command |
Status |
Duration |
Result |
nx test apps-automated -c=android |
✅ Succeeded |
3m 22s |
View ↗ |
nx run-many --target=test --configuration=ci --... |
✅ Succeeded |
<1s |
View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-10-29 14:46:22 UTC
|
Copy link
Copy Markdown
|
Open in StackBlitz
npm i https://pkg.pr.new/@nativescript/core@11592
npm i https://pkg.pr.new/@nativescript/vite@11592
npm i https://pkg.pr.new/@nativescript/webpack@11592
commit: 1d26c38
|
This branch has not been deployed
No deployments
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment
Labels
None yet
1 participant