We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8dd703d commit eb7a8dfCopy full SHA for eb7a8df
4 files changed
src/compiler/__tests__/@prop.test.tsx
@@ -40,6 +40,46 @@ test("@prop target (nested @media)", () => {
40
});
41
42
43
+test("@prop target unparsed", () => {
44
+ const compiled = registerCSS(`
45
+ :root {
46
+ --color-black: #000;
47
+ }
48
+
49
+ .my-class {
50
+ @prop test;
51
+ color: var(--color-black);
52
53
+ `);
54
55
+ expect(compiled.stylesheet()).toStrictEqual({
56
+ s: [
57
+ [
58
+ "my-class",
59
60
+ {
61
+ d: [[[{}, "var", "color-black", 1], ["test"], 1]],
62
+ dv: 1,
63
+ s: [2, 1],
64
+ v: [["__rn-css-current-color", [{}, "var", "color-black", 1]]],
65
+ },
66
+ ],
67
68
69
+ vr: [["color-black", [["#000"]]]],
70
+ });
71
72
+ render(<View testID={testID} className="my-class" />);
73
+ const component = screen.getByTestId(testID);
74
75
+ expect(component.props).toStrictEqual({
76
+ testID,
77
+ children: undefined,
78
+ test: "#000",
79
+ style: {},
80
81
+});
82
83
test("@prop value: target", () => {
84
const compiled = registerCSS(`
85
.my-class {
src/compiler/__tests__/declarations.test.tsx
@@ -6,10 +6,10 @@ const tests = [
6
["-rn-ripple-style: borderless;", [{ d: [[true, ["android_ripple", "borderless"]]], s: [1, 1] }]],
7
["caret-color: black", [{ d: [["#000", ["cursorColor"]]], s: [1, 1] }]],
8
["fill: black;", [{ d: [["#000", ["fill"]]], s: [1, 1] }]],
9
- ["stroke: black;", [{ d: [["#000", ["stroke"]]], s: [1, 1] }]],
10
- ["stroke-width: 1px;", [{ d: [[1, ["strokeWidth"]]], s: [1, 1] }]],
11
["rotate: 3deg;", [{ d: [[[{}, "rotateZ", "3deg"], "rotateZ"]], s: [1, 1] }]],
12
["rotate: x 3deg;", [{ d: [[[{}, "rotateX", "3deg"], "rotateX"]], s: [1, 1] }]],
+ ["stroke-width: 1px;", [{ d: [[1, ["strokeWidth"]]], s: [1, 1] }]],
+ ["stroke: black;", [{ d: [["#000", ["stroke"]]], s: [1, 1] }]],
13
] as const;
14
15
test.each(tests)("declarations for %s", (declarations, expected) => {
src/compiler/compiler.types.ts
@@ -99,10 +99,8 @@ export type StyleDeclaration =
99
| Record<string, StyleDescriptor>
100
/** A style that needs to be set */
101
| [StyleDescriptor, string | string[]]
102
- /** A value that can only be computed at runtime */
103
- | [StyleFunction, string | string[]]
104
/** A value that can only be computed at runtime, and only after styles have been calculated */
105
- | [StyleFunction, string | string[], 1];
+ | [StyleDescriptor, string | string[], 1];
106
107
export type StyleDescriptor =
108
| string
src/compiler/stylesheet.ts
@@ -410,22 +410,21 @@ export class StylesheetBuilder {
410
propPath = property;
411
}
412
413
- if (isStyleFunction(value)) {
+ if (forceTuple && !Array.isArray(propPath)) {
414
+ propPath = [propPath];
415
416
417
+ if (isStyleFunction(value) || Array.isArray(propPath)) {
418
if (delayed) {
419
declarations.push([value, propPath, 1]);
420
} else {
421
declarations.push([value, propPath]);
422
- } else if (forceTuple || Array.isArray(propPath)) {
- declarations.push([
- value,
- Array.isArray(propPath) ? propPath : [propPath],
423
- ]);
424
} else if (Array.isArray(value) && value.some(isStyleFunction)) {
425
426
} else if (typeof value === "string" && keywords.has(value)) {
427
428
- } else {
+ } else if (typeof propPath === "string") {
429
let staticDeclarationRecord = staticDeclarations.get(declarations);
430
if (!staticDeclarationRecord) {
431
staticDeclarationRecord = {};
0 commit comments