File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -293,3 +293,41 @@ test("@prop multiple", () => {
293293 ] ,
294294 } ) ;
295295} ) ;
296+
297+ test ( "@prop dot notation" , ( ) => {
298+ const compiled = 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 ( < View testID = { testID } className = "my-class" /> ) ;
323+ const component = 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+ } ) ;
Original file line number Diff line number Diff 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 return item . 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 return mapping ;
112124 }
You can’t perform that action at this time.
0 commit comments