Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99fdf44

Browse files
committed
fix: anonymous@prop usage
1 parent5b7b876 commit99fdf44

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,41 @@ test("@prop multiple", () => {
293293
],
294294
});
295295
});
296+
297+
test("@prop dot notation",()=>{
298+
constcompiled=registerCSS(`
299+
.my-class {
300+
@prop test.nested;
301+
@media all {
302+
color: red;
303+
}
304+
}
305+
`);
306+
307+
expect(compiled.stylesheet()).toStrictEqual({
308+
s:[
309+
[
310+
"my-class",
311+
[
312+
{
313+
d:[["#f00",["test","nested"]]],
314+
v:[["__rn-css-color","#f00"]],
315+
s:[2,1],
316+
},
317+
],
318+
],
319+
],
320+
});
321+
322+
render(<ViewtestID={testID}className="my-class"/>);
323+
constcomponent=screen.getByTestId(testID);
324+
325+
expect(component.props).toStrictEqual({
326+
children:undefined,
327+
style:{},
328+
test:{
329+
nested:"#f00",
330+
},
331+
testID:"react-native-css",
332+
});
333+
});

‎src/compiler/atRules.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,22 @@ function propAtRuleBlock(
103103
token:Extract<TokenOrValue,{type:"token"}>[],
104104
mapping:StyleRuleMapping={},
105105
):StyleRuleMapping{
106-
const[from,to]=splitByDelimiter(token,(item)=>{
106+
let[from,to]=splitByDelimiter(token,(item)=>{
107107
returnitem.value.type==="colon";
108108
});
109109

110+
//@props <to>; (has no from value)
111+
if(!to&&from){
112+
to=from;
113+
from=[
114+
{
115+
type:"token",
116+
value:{type:"ident",value:"*"},
117+
},
118+
];
119+
}
120+
121+
// We can only map from a single property
110122
if(!from||from.length!==1){
111123
returnmapping;
112124
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp