GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@triniwiz triniwiz commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Checklist

  • The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages.
  • There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
  • You have signed the CLA.
  • All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#running-unit-tests-application.
  • Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md.

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.

All reactions
triniwiz added 3 commits October 15, 2026 07:57
@triniwiz
fix(core): css var() fallbacks, initial, and order-independent custom…
9023e2e
… 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.
@triniwiz
fix(core): custom properties that cannot be resolved no longer crash …
7e10c8e
…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.
@triniwiz
fix(core): unset css property when its value fails to apply
2023aec
A value that throws when applied (e.g. var() resolving to an invalid
color) left the previously applied value in place. Per CSS Values 5,
a declaration invalid at computed-value time computes as unset.

https://drafts.csswg.org/css-values-5/#invalid-substitution
This was referenced Oct 15, 2026
fix(core): keyframes without a 0% or 100% keyframe animate from and to the view's own values #11528
Merged
fix(core): boolean properties and class substring operators in attribute selectors #11529
Open
feat(core): range syntax and rem/em lengths in media queries #11530
Open
feat(core): structural pseudo-classes and :root #11531
Open
feat(core): CSS Color 4 and 5 color functions #11532
Merged
@nx-cloud

nx-cloud Bot commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 15, 2026
feat(core): rem lengths #11533
Merged
fix(core): resolve var() in css animations and keyframes per view #11534
Merged
fix(core): keep a gesture's recognizer when its listener is swapped #11535
Open
fix(core): make background: none clear the background color #11536
Merged
fix(core): appearance APIs before app start, replaceable Android handlers, explicit systemAppearanceChanged() #11537
Merged
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@CatchABus

CatchABus commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@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
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@triniwiz
chore(core): drop comments
ac100b2
@NathanWalker

NathanWalker commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

NathanWalker
NathanWalker approved these changes Oct 29, 2026
View reviewed changes
@NathanWalker
NathanWalker merged commit 1044838 into main Oct 29, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@NathanWalker
NathanWalker deleted the fix/css-forward-var-refs branch October 29, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@NathanWalker NathanWalker NathanWalker approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@triniwiz @CatchABus @NathanWalker
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.