@@ -107,7 +107,7 @@ const plugin = (options = {}) => {
107
107
Once ( root , { rule } ) {
108
108
const exports = Object . create ( null ) ;
109
109
110
- function exportScopedName ( name , rawName , node , needExport = true ) {
110
+ function exportScopedName ( name , rawName , node ) {
111
111
const scopedName = generateScopedName (
112
112
rawName ? rawName : name ,
113
113
root . source . input . from ,
@@ -123,10 +123,6 @@ const plugin = (options = {}) => {
123
123
) ;
124
124
const { key, value } = exportEntry ;
125
125
126
- if ( ! needExport ) {
127
- return scopedName ;
128
- }
129
-
130
126
exports [ key ] = exports [ key ] || [ ] ;
131
127
132
128
if ( exports [ key ] . indexOf ( value ) < 0 ) {
@@ -136,27 +132,25 @@ const plugin = (options = {}) => {
136
132
return scopedName ;
137
133
}
138
134
139
- function localizeNode ( node , needExport = true ) {
135
+ function localizeNode ( node ) {
140
136
switch ( node . type ) {
141
137
case "selector" :
142
- node . nodes = node . map ( ( item ) => localizeNode ( item , needExport ) ) ;
138
+ node . nodes = node . map ( ( item ) => localizeNode ( item ) ) ;
143
139
return node ;
144
140
case "class" :
145
141
return selectorParser . className ( {
146
142
value : exportScopedName (
147
143
node . value ,
148
144
node . raws && node . raws . value ? node . raws . value : null ,
149
- node ,
150
- needExport
145
+ node
151
146
) ,
152
147
} ) ;
153
148
case "id" : {
154
149
return selectorParser . id ( {
155
150
value : exportScopedName (
156
151
node . value ,
157
152
node . raws && node . raws . value ? node . raws . value : null ,
158
- node ,
159
- needExport
153
+ node
160
154
) ,
161
155
} ) ;
162
156
}
@@ -166,7 +160,7 @@ const plugin = (options = {}) => {
166
160
attribute : node . attribute ,
167
161
operator : node . operator ,
168
162
quoteMark : "'" ,
169
- value : exportScopedName ( node . value , null , null , needExport ) ,
163
+ value : exportScopedName ( node . value , null , null ) ,
170
164
} ) ;
171
165
}
172
166
}
@@ -236,35 +230,39 @@ const plugin = (options = {}) => {
236
230
237
231
rule . selector = traverseNode ( parsedSelector . clone ( ) ) . toString ( ) ;
238
232
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 ) => {
240
234
const localNames = getSingleLocalNamesForComposes (
241
235
parsedSelector ,
242
236
decl . parent
243
237
) ;
244
- const classes = decl . value . split ( / \s + / ) ;
238
+ const multiple = decl . value . split ( "," ) ;
245
239
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 + / ) ;
248
242
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 ] ) ;
261
249
} ) ;
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
+ } ) ;
268
266
} ) ;
269
267
270
268
decl . remove ( ) ;
0 commit comments