From ccc6848094b39a943745b1f9a112efc0e1d43695 Mon Sep 17 00:00:00 2001 From: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com> Date: Fri, 6 Nov 2026 14:48:29 -0500 Subject: [PATCH] fix(compiler): ignore an @property whose initial value depends on the element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/__tests__/compiler/property.test.ts | 99 ++++++++++ .../native/non-inheriting-variables.test.tsx | 33 ++++ src/compiler/compiler.ts | 9 +- src/compiler/computational-independence.ts | 169 ++++++++++++++++++ 4 files changed, 308 insertions(+), 2 deletions(-) create mode 100644 src/compiler/computational-independence.ts diff --git a/src/__tests__/compiler/property.test.ts b/src/__tests__/compiler/property.test.ts index 11d7b564..b3cfb2dc 100644 --- a/src/__tests__/compiler/property.test.ts +++ b/src/__tests__/compiler/property.test.ts @@ -382,6 +382,15 @@ test("the last @property declaration of a name decides inherits", () => { expect(nonInheritingLast.stylesheet().vp).toStrictEqual([["flip", false]]); }); +test("an ignored @property leaves the earlier registration of its name", () => { + const result = compile(` +@property --x { syntax: ""; inherits: false; initial-value: 3px; } +@property --x { syntax: ""; inherits: true; initial-value: 2em; } +`).stylesheet(); + + expect(result.vp).toStrictEqual([["x", false, 3]]); +}); + test.each([ ["