File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -204,16 +204,25 @@ module.exports = postcss.plugin('postcss-modules-local-by-default', function (op
204
204
if ( / k e y f r a m e s $ / . test ( atrule . name ) ) {
205
205
var globalMatch = / ^ \s * : g l o b a l \s * \( ( .+ ) \) \s * $ / . exec ( atrule . params ) ;
206
206
var localMatch = / ^ \s * : l o c a l \s * \( ( .+ ) \) \s * $ / . exec ( atrule . params ) ;
207
+ var globalKeyframes = globalMode ;
207
208
if ( globalMatch ) {
208
209
if ( pureMode ) {
209
210
throw atrule . error ( '@keyframes :global(...) is not allowed in pure mode' ) ;
210
211
}
211
212
atrule . params = globalMatch [ 1 ] ;
213
+ globalKeyframes = true ;
212
214
} else if ( localMatch ) {
213
215
atrule . params = localMatch [ 0 ] ;
216
+ globalKeyframes = false ;
214
217
} else if ( ! globalMode ) {
215
218
atrule . params = ':local(' + atrule . params + ')' ;
216
219
}
220
+ atrule . walkDecls ( function ( decl ) {
221
+ localizeDecl ( decl , {
222
+ options : options ,
223
+ global : globalKeyframes
224
+ } ) ;
225
+ } ) ;
217
226
} else if ( atrule . nodes ) {
218
227
atrule . nodes . forEach ( function ( decl ) {
219
228
if ( decl . type === 'decl' ) {
Original file line number Diff line number Diff line change @@ -364,7 +364,10 @@ var tests = [
364
364
':global .b { background: url(image.png); }\n' +
365
365
'.c { background: url("./image.png"); }\n' +
366
366
'@font-face { src: url("./font.woff"); }\n' +
367
- '@-webkit-font-face { src: url("./font.woff"); }' ,
367
+ '@-webkit-font-face { src: url("./font.woff"); }\n' +
368
+ '@media screen { .a { src: url("./image.png"); } }\n' +
369
+ '@keyframes :global(ani1) { 0% { src: url("image.png"); } }\n' +
370
+ '@keyframes ani2 { 0% { src: url("./image.png"); } }' ,
368
371
options : {
369
372
rewriteUrl : function ( global , url ) {
370
373
var mode = global ? 'global' : 'local' ;
@@ -375,7 +378,10 @@ var tests = [
375
378
'.b { background: url((global\\)image.png\\\"global\\\"); }\n' +
376
379
':local(.c) { background: url(\"(local)./image.png\\\"local\\\"\"); }\n' +
377
380
'@font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }\n' +
378
- '@-webkit-font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }'
381
+ '@-webkit-font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }\n' +
382
+ '@media screen { :local(.a) { src: url("(local)./image.png\\"local\\""); } }\n' +
383
+ '@keyframes ani1 { 0% { src: url("(global)image.png\\"global\\""); } }\n' +
384
+ '@keyframes :local(ani2) { 0% { src: url("(local)./image.png\\"local\\""); } }'
379
385
} ,
380
386
{
381
387
should : 'not crash on atrule without nodes' ,
You can’t perform that action at this time.
0 commit comments