A value read through `var()` that the property can't take still applies: `border: var(--b)` over `--b: 1px, solid` draws a border, and `border-inline-width` over `red` keeps an earlier width
メンテナーはふだん 5 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react-native, typescript
調査の方向性
Start with the reproducer src/__tests__/native/comma-list-in-a-variable.test.tsx and run it to see the four logged cases. The comma-list case is in shorthandHandler in src/native/styles/shorthands/_handler.ts, which calls args.flat() before matching patterns. The refused-value case is in logicalWidth in src/native/styles/shorthands/logical-border-width.ts, which returns undefined where the keys should be unset. Done when the expected outputs hold on both the folded and inlineVariables: false routes; check the interaction with #547 before changing the list handling.
索引モデルが issue の本文から書いたものです。
説明
Before submitting a new issue
- I tested using the latest version of the library, as the bug might be already fixed.
- I tested using a supported version of react native.
- I checked for possible duplicate issues, with possible answers.
Bug summary
In CSS a var() whose value doesn't fit the property's grammar makes the declaration invalid at computed-value time (css-variables-1 §3): the property is unset, and an earlier rule's value for it no longer applies. The shorthand readers get both halves of that wrong, on the folded route and with inlineVariables: false alike:
- A comma list is read as a space list.
borderandborder-inline-widthhave no comma in their grammar, yetborder: var(--b)over--b: 1px, soliddraws a 1px solid border, andborder-inline-width: var(--w)over--w: 1px, 2pxapplies 1 and 2, as if the value were written1px 2px. - A refused value leaves the earlier one.
border-inline-width: var(--w)andborder-block-width: var(--w)over--w: redare refused, but an earlier rule's5pxstays, where the property should be unset.
folded .a { --b: 1px, solid; border: var(--b); }
=> {"borderWidth":1,"borderStyle":"solid"}
kept .a { --b: 1px, solid; border: var(--b); }
=> {"borderWidth":1,"borderStyle":"solid"}
folded .earlier { border-inline-width: 5px; } .a { --w: 1px, 2px; border-inline-width: var(--w); }
=> {"borderStartWidth":1,"borderEndWidth":2}
kept .earlier { border-inline-width: 5px; } .a { --w: 1px, 2px; border-inline-width: var(--w); }
=> {"borderStartWidth":1,"borderEndWidth":2}
folded .earlier { border-inline-width: 5px; } .a { --w: red; border-inline-width: var(--w); }
=> {"borderStartWidth":5,"borderEndWidth":5}
kept .earlier { border-inline-width: 5px; } .a { --w: red; border-inline-width: var(--w); }
=> {"borderStartWidth":5,"borderEndWidth":5}
folded .earlier { border-block-width: 5px; } .a { --w: red; border-block-width: var(--w); }
=> {"borderTopWidth":5,"borderBottomWidth":5}
kept .earlier { border-block-width: 5px; } .a { --w: red; border-block-width: var(--w); }
=> {"borderTopWidth":5,"borderBottomWidth":5}
shorthandHandler(src/native/styles/shorthands/_handler.ts) runsargs = args.flat()on the resolved value before matching it against the shorthand's patterns, so a comma-separated list's items match as one space-separated list.logicalWidth(src/native/styles/shorthands/logical-border-width.ts) returnsundefinedfor a value that isn't one or two finite non-negative numbers, andundefinedsets nothing, so the earlier rule's width stays; returning the two keys asnullwould unset them.
I've filed them together since they're the same rule failing in two readers that share one harness. #547 keeps a list's separator when it's read through a variable, so it makes case 1 a refusal for border-inline-width, which then lands in case 2.
Library version
main at a37903f (0.0.0-nightly.a37903f)
Environment info
Windows 11 10.0.26300, Node 26.12.1, Yarn 4.9.2, react-native 0.86.3 (the repository's dev dependency).
No app or native build is involved: the output comes from the repository's jest setup.
Steps to reproduce
- Clone the reproducer branch, which is
mainat a37903f with one file added,src/__tests__/native/comma-list-in-a-variable.test.tsx, and install:git clone --branch repro/552-comma-list-read-as-a-space-list https://github.com/YevheniiKotyrlo/react-native-css cd react-native-css yarn install - Run
yarn jest src/__tests__/native/comma-list-in-a-variable.test.tsxand read the logged lines.
src/__tests__/native/comma-list-in-a-variable.test.tsx:
import { StyleSheet } from "react-native";
import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, testID } from "react-native-css/jest";
jest.mock("../../native/reanimated", () => ({
animatedComponentFamily: (component: unknown) => component,
}));
test.each([
".a { --b: 1px, solid; border: var(--b); }",
".earlier { border-inline-width: 5px; } .a { --w: 1px, 2px; border-inline-width: var(--w); }",
".earlier { border-inline-width: 5px; } .a { --w: red; border-inline-width: var(--w); }",
".earlier { border-block-width: 5px; } .a { --w: red; border-block-width: var(--w); }",
])("%s", (css) => {
for (const inlineVariables of [true, false]) {
registerCSS(css, inlineVariables ? {} : { inlineVariables: false });
render(<View testID={testID} className="earlier a" />);
console.log(
`${inlineVariables ? "folded" : "kept "} ${css}\n => ${JSON.stringify(StyleSheet.flatten(screen.getByTestId(testID).props.style))}`,
);
screen.unmount();
}
});
Expected: border: var(--b) over 1px, solid draws no border; border-inline-width: var(--w) over 1px, 2px or red sets neither borderStartWidth nor borderEndWidth, so the earlier 5px no longer applies; the same for border-block-width.
Actual: the border is drawn 1px solid, 1px, 2px applies 1 and 2, and red leaves the earlier 5px.
The run's output on main at a37903f, Windows 11, Node 26.12.1
console.log
folded .a { --b: 1px, solid; border: var(--b); }
=> {"borderWidth":1,"borderStyle":"solid"}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
kept .a { --b: 1px, solid; border: var(--b); }
=> {"borderWidth":1,"borderStyle":"solid"}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
folded .earlier { border-inline-width: 5px; } .a { --w: 1px, 2px; border-inline-width: var(--w); }
=> {"borderStartWidth":1,"borderEndWidth":2}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
kept .earlier { border-inline-width: 5px; } .a { --w: 1px, 2px; border-inline-width: var(--w); }
=> {"borderStartWidth":1,"borderEndWidth":2}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
folded .earlier { border-inline-width: 5px; } .a { --w: red; border-inline-width: var(--w); }
=> {"borderStartWidth":5,"borderEndWidth":5}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
kept .earlier { border-inline-width: 5px; } .a { --w: red; border-inline-width: var(--w); }
=> {"borderStartWidth":5,"borderEndWidth":5}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
folded .earlier { border-block-width: 5px; } .a { --w: red; border-block-width: var(--w); }
=> {"borderTopWidth":5,"borderBottomWidth":5}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
console.log
kept .earlier { border-block-width: 5px; } .a { --w: red; border-block-width: var(--w); }
=> {"borderTopWidth":5,"borderBottomWidth":5}
at log (src/__tests__/native/comma-list-in-a-variable.test.tsx:20:13)
PASS src/__tests__/native/comma-list-in-a-variable.test.tsx
√ .a { --b: 1px, solid; border: var(--b); } (31 ms)
√ .earlier { border-inline-width: 5px; } .a { --w: 1px, 2px; border-inline-width: var(--w); } (5 ms)
√ .earlier { border-inline-width: 5px; } .a { --w: red; border-inline-width: var(--w); } (3 ms)
√ .earlier { border-block-width: 5px; } .a { --w: red; border-block-width: var(--w); } (2 ms)
Test Suites: 1 passed, 1 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 1.684 s, estimated 2 s
Ran all test suites matching /src\\__tests__\\native\\comma-list-in-a-variable.test.tsx/i.
Reproducible example repository
https://github.com/YevheniiKotyrlo/react-native-css/tree/repro/552-comma-list-read-as-a-space-list
- 主要言語
- TypeScript
- スター
- 166
- フォーク
- 45
- 平均マージ
- 10日 1時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nativewind/react-native-css のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
nativewind/react-native-css#554 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nativewind/react-native-css#549 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nativewind/react-native-css#548 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nativewind/react-native-css#545 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nativewind/react-native-css#544 ·
メンテナーはふだん 5 日以内に返信
nativewind/react-native-css の issue をすべて見る
似ている issue
-
[Text] Add Reading Time & Word Count Estimator for Reflection Notes in src/lib/text/reading-time.tsオープンarea:core beginner-friendly community contributions-welcome difficulty:easy enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
[fullsend] E2E: scorecard — filecheck GitLab entity metrics unavailable due to initialDelay timingオープンe2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
redhat-developer/rhdh-plugin-export-overlays#4698 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
devswha/herdr-web-ui#2884 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
b:minor bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
software-mansion/argent#1771 ·
メンテナーはふだん 1 日以内に返信