File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
33const getDeclsObject = rule => {
44 const object = { } ;
55 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 ;
78 } ) ;
89 return object ;
910} ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ test("extract :import statements with single quoted path", () => {
2727 } ) ;
2828} ) ;
2929
30- test ( "extract :import statements with double quoted path " , ( ) => {
30+ test ( "extract manually added :import " , ( ) => {
3131 expect ( runExtract ( ':import("./colors.css") {}' ) ) . toEqual ( {
3232 icssImports : {
3333 "./colors.css" : { }
@@ -50,6 +50,25 @@ test("not extract :import with values", () => {
5050 } ) ;
5151} ) ;
5252
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+
5372test ( "not extract invalid :import" , ( ) => {
5473 expect ( runExtract ( ":import(\\'./colors.css) {}" ) ) . toEqual ( {
5574 icssImports : { } ,
You can’t perform that action at this time.
0 commit comments