File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
3
3
const getDeclsObject = rule => {
4
4
const object = { } ;
5
5
rule . walkDecls ( decl => {
6
- object [ decl . raws . before . trim ( ) + decl . prop ] = decl . value ;
6
+ const before = decl . raws . before ? decl . raws . before . trim ( ) : "" ;
7
+ object [ before + decl . prop ] = decl . value ;
7
8
} ) ;
8
9
return object ;
9
10
} ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ test("extract :import statements with single quoted path", () => {
27
27
} ) ;
28
28
} ) ;
29
29
30
- test ( "extract :import statements with double quoted path " , ( ) => {
30
+ test ( "extract manually added :import " , ( ) => {
31
31
expect ( runExtract ( ':import("./colors.css") {}' ) ) . toEqual ( {
32
32
icssImports : {
33
33
"./colors.css" : { }
@@ -50,6 +50,25 @@ test("not extract :import with values", () => {
50
50
} ) ;
51
51
} ) ;
52
52
53
+ test ( "extract :import statements manually created in postcss" , ( ) => {
54
+ const root = postcss . parse ( "" ) ;
55
+ root . append (
56
+ postcss
57
+ . rule ( { selector : ":import(./colors.css)" } )
58
+ . append ( postcss . decl ( { prop : "i__blue" , value : "blue" } ) )
59
+ . append ( postcss . decl ( { prop : "i__red" , value : "red" } ) )
60
+ ) ;
61
+ expect ( extractICSS ( root ) ) . toEqual ( {
62
+ icssImports : {
63
+ "./colors.css" : {
64
+ i__blue : "blue" ,
65
+ i__red : "red"
66
+ }
67
+ } ,
68
+ icssExports : { }
69
+ } ) ;
70
+ } ) ;
71
+
53
72
test ( "not extract invalid :import" , ( ) => {
54
73
expect ( runExtract ( ":import(\\'./colors.css) {}" ) ) . toEqual ( {
55
74
icssImports : { } ,
You can’t perform that action at this time.
0 commit comments