Skip to content

fix(compiler): ignore an @property whose initial value depends on the element - #599

Merged
danstepanov merged 1 commit into
nativewind:mainfrom
YevheniiKotyrlo:fix/property-initial-value-independence
Dec 4, 2026
Merged

danstepanov merged 1 commit into
nativewind:mainfrom
YevheniiKotyrlo:fix/property-initial-value-independence

Conversation

@YevheniiKotyrlo

@YevheniiKotyrlo YevheniiKotyrlo commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An @property initial-value must be computationally independent (css-properties-values-api-1, the initial-value descriptor), so a registration whose initial value uses a font- or container-relative unit (em, rem, ch, lh, cq*, …), including inside calc(), a math function or a transform function, is invalid, and the earlier registration of its name stays in force. Chromium 153, Firefox 155 and WebKit 26.6 ignore one in a font-relative unit; Chromium and WebKit also ignore one in a cq* unit, which Firefox still registers. The compiler registers every one.

Solution

src/compiler/computational-independence.ts decides whether an initial value is computationally independent, and collectRegistrations skips a registration whose initial value is not. An <image> initial value is kept as written.

This is the patch split out of #412, whose inherits: false part landed in #567, with one change: the inliner test declares its variable on :root, since #592 folds a single declaration only within its own block.

Tests

  • src/__tests__/compiler/property.test.ts: an ignored registration leaves the earlier one of its name; initial values in units and math functions, and the <transform-function> / <transform-list> cases, decide validity; an <image> registration with an element-relative stop still decides its name; an ignored non-inheriting registration lets the inliner fold a :root declaration of its name.
  • src/__tests__/native/non-inheriting-variables.test.tsx: an ignored non-inheriting registration lets the property inherit, and an ignored registration leaves the earlier one of its name in force.

Verification

A local replica of CI passes every job on Node 26.12.1, where .nvmrc pins 24.22.3: lint and typecheck, yarn test --maxWorkers=2 --coverage (2268 passed), the library build with node --test, the web export and commitlint in Ubuntu, and the iOS dev build on macOS with Xcode 27.2, where ci.yml pins 26.6.

@YevheniiKotyrlo
YevheniiKotyrlo marked this pull request as ready for review December 2, 2026 16:54

@sammoore sammoore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this one!

… element

An @Property initial-value must be computationally independent
(css-properties-values-api-1 §3). A registration whose initial value uses
a font- or container-relative unit (em, rem, ch, lh, cq*, ...), including
inside calc(), a math function or a transform, is invalid, and browsers
ignore it, so the earlier registration of its name stays in force.
@danstepanov
danstepanov force-pushed the fix/property-initial-value-independence branch from 096656d to ccc6848 Compare December 4, 2026 03:11
@danstepanov
danstepanov merged commit 4d1b80d into nativewind:main Dec 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants