GeezerVison is showing github.com — fix(core): css var() fallbacks, order-independent custom properties, and no crash on unresolvable ones by triniwiz · Pull Request #11527 · NativeScript/NativeScript
Conversation
triniwiz
commented
Oct 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
PR Checklist
What is the current behavior?
- A custom property whose
var() cannot be resolved is stored as core's unsetValue sentinel. When another variable reads it, evaluation calls .trim() on the sentinel and throws, which aborts styling of the view. A stylesheet with a chain of forward references (--a: var(--b) before --b, as Bootstrap writes its variables) renders the app blank.
var() fallbacks are cut at the first ) and the first ,, so var(--x, rgb(0, 0, 255)) and comma lists such as gradient stops are truncated.
- Custom properties are only resolved in declaration order.
- A value that throws when applied (e.g.
var() resolving to an invalid color) leaves the previously applied value in place.
What is the new behavior?
var() finds its matching closing parenthesis, and the fallback is everything after the first comma, as the spec requires.
- A custom property set to
initial uses the var() fallback.
- Custom properties are settled before the properties that use them, and re-evaluated when one refers to another declared after it.
- A custom property that cannot be resolved holds
null, CSS's guaranteed-invalid value: var() takes its fallback and the parent's value does not show through. Properties in a cycle resolve the same way. This is the crash fix.
- A declaration that is invalid at computed-value time computes as
unset instead of keeping the previous value (css-values-5).
Tests: css-variable-expression.spec.ts and style-scope.spec.ts (forward-reference chains, cycles, an unresolvable variable not inheriting the parent's value, invalid values unsetting). The chain and cycle tests reproduce the TypeError without the fix. The apps/automated expectation for var(--undefined-var, var(--my-fallback-var), yellow) changes from lime to unset, which is what browsers do (lime, yellow is not a color). The automated suite passes on an Android emulator (API 36) with this branch merged with the other CSS PRs.
Verified with all of these core PRs merged together (#11527–#11537): apps/automated passes on the iOS 26.4 simulator (1830 OK, 0 failed) and on an Android API 36 emulator (1692 OK; the one failure is the network-dependent IMAGE-CACHE.test_ImageCache_ValidUrl timeout, which also passes on reruns).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
… properties
- var() finds its matching closing parenthesis, so fallbacks such as
rgb(...) are no longer truncated.
- The fallback is everything after the first comma, so comma lists
(e.g. gradient stops) survive. var(--missing, a, b) now resolves to
"a, b" as the spec requires, instead of "a".
- A custom property set to `initial` uses the var() fallback.
- Custom properties are settled before the properties that use them, and
re-evaluated when one refers to another declared after it.
…styling
A custom property whose var() could not be resolved was stored as the
unsetValue sentinel. When another variable read it, evaluation called
.trim() on it and threw, which aborted styling of the view: a stylesheet
with a chain of forward references (--a: var(--b) before --b, as
Bootstrap writes them) rendered blank.
Such a property now holds null, CSS's guaranteed-invalid value: var()
takes its fallback, and the parent's value does not show through. Custom
properties in a cycle resolve the same way.
This was referenced Oct 15, 2026
nx-cloud
Bot
commented
Oct 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
View your CI Pipeline Execution ↗ for commit ac100b2
| Command |
Status |
Duration |
Result |
nx test apps-automated -c=android |
✅ Succeeded |
5m 27s |
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-15 20:38:25 UTC
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 15, 2026
pkg-pr-new
Bot
commented
Oct 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Open in StackBlitz
npm i https://pkg.pr.new/@nativescript/core@11527
npm i https://pkg.pr.new/@nativescript/vite@11527
npm i https://pkg.pr.new/@nativescript/webpack@11527
commit: ac100b2
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
CatchABus
commented
Oct 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
@triniwiz You might also get ideas from my draft work:
#10776
I think I left it as draft because my parser is using csstools tokenizer and parser deps underneath and that makes it a bit slower.
|
triniwiz reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@CatchABus thanks for pointing to #10776, it was useful prior art. Between this PR and #11593, most of what it aimed for is covered:
var() fallbacks keep nested parentheses and commas: var(--x, rgb(0, 0, 255)) and gradient stop lists come through whole.
- Custom properties that refer to ones declared later resolve correctly, including chains across separate rules, and cycles fall back instead of crashing.
- A
var() that can't be resolved inside a larger value (10 10 5 12 var(--missing), calc(), color-mix()) makes the whole declaration invalid (fix(core): unresolved var() unsets the whole value and invalid color-mix() no longer renders white #11593), as your draft's box-shadow test expected.
Two places we went a different way:
- Fallback meaning: the fallback is everything after the first comma, as the spec says, rather than a list of fallbacks to try one by one. So
var(--undefined, var(--fb), yellow) computes as unset (lime, yellow isn't a color), which matches browsers.
- Parsing: we used a simple parenthesis counter instead of the csstools tokenizer, given the speed cost you mentioned. The trade-off is that a
) inside a quoted string in a fallback isn't handled.
Your idea of resolving each variable when something first asks for it is nicer than our repeated passes. If you want to bring it over later, it would replace settleCssVariables. Otherwise I think #10776 can be closed. Let us know if it covers something we missed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|