@@ -107,7 +107,7 @@ const plugin = (options = {}) => {
107107 Once ( root , { rule } ) {
108108 const exports = Object . create ( null ) ;
109109
110- function exportScopedName ( name , rawName , node , needExport = true ) {
110+ function exportScopedName ( name , rawName , node ) {
111111 const scopedName = generateScopedName (
112112 rawName ? rawName : name ,
113113 root . source . input . from ,
@@ -123,10 +123,6 @@ const plugin = (options = {}) => {
123123 ) ;
124124 const { key, value } = exportEntry ;
125125
126- if ( ! needExport ) {
127- return scopedName ;
128- }
129-
130126 exports [ key ] = exports [ key ] || [ ] ;
131127
132128 if ( exports [ key ] . indexOf ( value ) < 0 ) {
@@ -136,27 +132,25 @@ const plugin = (options = {}) => {
136132 return scopedName ;
137133 }
138134
139- function localizeNode ( node , needExport = true ) {
135+ function localizeNode ( node ) {
140136 switch ( node . type ) {
141137 case "selector" :
142- node . nodes = node . map ( ( item ) => localizeNode ( item , needExport ) ) ;
138+ node . nodes = node . map ( ( item ) => localizeNode ( item ) ) ;
143139 return node ;
144140 case "class" :
145141 return selectorParser . className ( {
146142 value : exportScopedName (
147143 node . value ,
148144 node . raws && node . raws . value ? node . raws . value : null ,
149- node ,
150- needExport
145+ node
151146 ) ,
152147 } ) ;
153148 case "id" : {
154149 return selectorParser . id ( {
155150 value : exportScopedName (
156151 node . value ,
157152 node . raws && node . raws . value ? node . raws . value : null ,
158- node ,
159- needExport
153+ node
160154 ) ,
161155 } ) ;
162156 }
@@ -166,7 +160,7 @@ const plugin = (options = {}) => {
166160 attribute : node . attribute ,
167161 operator : node . operator ,
168162 quoteMark : "'" ,
169- value : exportScopedName ( node . value , null , null , needExport ) ,
163+ value : exportScopedName ( node . value , null , null ) ,
170164 } ) ;
171165 }
172166 }
@@ -236,35 +230,39 @@ const plugin = (options = {}) => {
236230
237231 rule . selector = traverseNode ( parsedSelector . clone ( ) ) . toString ( ) ;
238232
239- rule . walkDecls ( / c o m p o s e s | c o m p o s e - w i t h / i, ( decl ) => {
233+ rule . walkDecls ( / ^ ( c o m p o s e s | c o m p o s e - w i t h ) $ / i, ( decl ) => {
240234 const localNames = getSingleLocalNamesForComposes (
241235 parsedSelector ,
242236 decl . parent
243237 ) ;
244- const classes = decl . value . split ( / \s + / ) ;
238+ const multiple = decl . value . split ( "," ) ;
245239
246- classes . forEach ( ( className ) => {
247- const global = / ^ g l o b a l \( ( [ ^ ) ] + ) \) $ / . exec ( className ) ;
240+ multiple . forEach ( ( value ) => {
241+ const classes = value . trim ( ) . split ( / \s + / ) ;
248242
249- if ( global ) {
250- localNames . forEach ( ( exportedName ) => {
251- exports [ exportedName ] . push ( global [ 1 ] ) ;
252- } ) ;
253- } else if ( hasOwnProperty . call ( importedNames , className ) ) {
254- localNames . forEach ( ( exportedName ) => {
255- exports [ exportedName ] . push ( className ) ;
256- } ) ;
257- } else if ( hasOwnProperty . call ( exports , className ) ) {
258- localNames . forEach ( ( exportedName ) => {
259- exports [ className ] . forEach ( ( item ) => {
260- exports [ exportedName ] . push ( item ) ;
243+ classes . forEach ( ( className ) => {
244+ const global = / ^ g l o b a l \( ( [ ^ ) ] + ) \) $ / . exec ( className ) ;
245+
246+ if ( global ) {
247+ localNames . forEach ( ( exportedName ) => {
248+ exports [ exportedName ] . push ( global [ 1 ] ) ;
261249 } ) ;
262- } ) ;
263- } else {
264- throw decl . error (
265- `referenced class name "${ className } " in ${ decl . prop } not found`
266- ) ;
267- }
250+ } else if ( hasOwnProperty . call ( importedNames , className ) ) {
251+ localNames . forEach ( ( exportedName ) => {
252+ exports [ exportedName ] . push ( className ) ;
253+ } ) ;
254+ } else if ( hasOwnProperty . call ( exports , className ) ) {
255+ localNames . forEach ( ( exportedName ) => {
256+ exports [ className ] . forEach ( ( item ) => {
257+ exports [ exportedName ] . push ( item ) ;
258+ } ) ;
259+ } ) ;
260+ } else {
261+ throw decl . error (
262+ `referenced class name "${ className } " in ${ decl . prop } not found`
263+ ) ;
264+ }
265+ } ) ;
268266 } ) ;
269267
270268 decl . remove ( ) ;
0 commit comments