Skip to content

Commit 81d3fdb

Browse files
committed
fix: change wildcard to nesting in @prop
1 parent 08286a2 commit 81d3fdb

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

src/__tests__/compiler/@prop.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test("@prop value: wildcard target", () => {
196196
.test {
197197
color: red;
198198
background-color: blue;
199-
@prop background-color: *.myBackgroundColor;
199+
@prop background-color: &.myBackgroundColor;
200200
}
201201
`);
202202

@@ -226,7 +226,7 @@ test("@prop value: wildcard nested target", () => {
226226
.my-class {
227227
color: red;
228228
background-color: blue;
229-
@prop background-color: *.myBackgroundColor.test;
229+
@prop background-color: &.myBackgroundColor.test;
230230
}
231231
`);
232232

@@ -240,7 +240,7 @@ test("@prop value: wildcard nested target", () => {
240240
{
241241
color: "#f00",
242242
},
243-
["#00f", ["*", "myBackgroundColor", "test"]],
243+
["#00f", ["&", "myBackgroundColor", "test"]],
244244
],
245245
v: [["__rn-css-color", "#f00"]],
246246
s: [1, 1],
@@ -267,8 +267,8 @@ test("@prop multiple", () => {
267267
color: red;
268268
background-color: oklab(40.1% 0.1143 0.045);
269269
@prop {
270-
background-color: *.myBackgroundColor;
271-
color: *.myColor;
270+
background-color: &.myBackgroundColor;
271+
color: &.myColor;
272272
}
273273
}
274274
`);

src/compiler/atRules.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,22 @@ function propAtRuleBlock(
128128
return mapping;
129129
}
130130

131-
mapping[toRNProperty(fromToken.value.value)] = to.flatMap((item, index) => {
131+
let value: string | string[] = to.flatMap((item, index) => {
132132
switch (item.value.type) {
133133
case "delim":
134-
return index === 0 && item.value.value === "*" ? ["*"] : [];
134+
return index === 0 && item.value.value === "&" ? ["&"] : [];
135135
case "ident":
136136
return item.value.value.split(".").map((part) => toRNProperty(part));
137137
default:
138138
return [];
139139
}
140140
});
141141

142+
if (value.length === 2 && value[0] === "&" && value[1]) {
143+
value = value[1];
144+
}
145+
146+
mapping[toRNProperty(fromToken.value.value)] = value;
147+
142148
return mapping;
143149
}

src/compiler/declarations.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,11 +1984,11 @@ export function parseTextShadow(
19841984
parseColor(textShadow.color, builder),
19851985
);
19861986
builder.addDescriptor(
1987-
"*.textShadowOffset.width",
1987+
"&.textShadowOffset.width",
19881988
parseLength(textShadow.xOffset, builder),
19891989
);
19901990
builder.addDescriptor(
1991-
"*.textShadowOffset.height",
1991+
"&.textShadowOffset.height",
19921992
parseLength(textShadow.yOffset, builder),
19931993
);
19941994
builder.addDescriptor(
@@ -2374,27 +2374,27 @@ export function parseBoxShadow(
23742374
) {
23752375
for (const [index, shadow] of value.entries()) {
23762376
builder.addDescriptor(
2377-
`*.boxShadow.[${index}].color`,
2377+
`&.boxShadow.[${index}].color`,
23782378
parseColor(shadow.color, builder),
23792379
);
23802380
builder.addDescriptor(
2381-
`*.boxShadow.[${index}].offsetX`,
2381+
`&.boxShadow.[${index}].offsetX`,
23822382
parseLength(shadow.xOffset, builder),
23832383
);
23842384
builder.addDescriptor(
2385-
`*.boxShadow.[${index}].offsetY`,
2385+
`&.boxShadow.[${index}].offsetY`,
23862386
parseLength(shadow.yOffset, builder),
23872387
);
23882388
builder.addDescriptor(
2389-
`*.boxShadow.[${index}].blurRadius`,
2389+
`&.boxShadow.[${index}].blurRadius`,
23902390
parseLength(shadow.blur, builder),
23912391
);
23922392
builder.addDescriptor(
2393-
`*.boxShadow.[${index}].spreadDistance`,
2393+
`&.boxShadow.[${index}].spreadDistance`,
23942394
parseLength(shadow.spread, builder),
23952395
);
23962396
builder.addDescriptor(
2397-
`*.boxShadow.[${index}].inset`,
2397+
`&.boxShadow.[${index}].inset`,
23982398
shadow.inset ? true : undefined,
23992399
);
24002400
}
@@ -3088,7 +3088,7 @@ function parseObjectFit(
30883088
builder: StylesheetBuilder,
30893089
) {
30903090
builder.addMapping({
3091-
"object-fit": "contentFit",
3091+
"object-fit": ["contentFit"],
30923092
});
30933093
builder.addDescriptor(
30943094
"object-fit",
@@ -3101,7 +3101,7 @@ function parseObjectPosition(
31013101
builder: StylesheetBuilder,
31023102
) {
31033103
builder.addMapping({
3104-
"object-position": "contentPosition",
3104+
"object-position": ["contentPosition"],
31053105
});
31063106
builder.addDescriptor("object-position", [
31073107
{},

src/compiler/stylesheet.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,10 @@ export class StylesheetBuilder {
403403
} else {
404404
forceTuple = true;
405405
}
406-
} else if (propPath) {
407-
forceTuple = true;
408-
} else {
409-
propPath = property;
410406
}
411407

408+
propPath ??= property;
409+
412410
if (forceTuple && !Array.isArray(propPath)) {
413411
propPath = [propPath];
414412
}

src/native/styles/calculate-props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function applyDeclarations(
129129
const final = rest.pop();
130130

131131
if (final) {
132-
if (first !== "*") {
132+
if (first !== "&") {
133133
topLevelTarget[first] ??= {};
134134
target = topLevelTarget[first];
135135
}

0 commit comments

Comments
 (0)