File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 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
204204 if ( / k e y f r a m e s $ / . test ( atrule . name ) ) {
205205 var globalMatch = / ^ \s * : g l o b a l \s * \( ( .+ ) \) \s * $ / . exec ( atrule . params ) ;
206206 var localMatch = / ^ \s * : l o c a l \s * \( ( .+ ) \) \s * $ / . exec ( atrule . params ) ;
207+ var globalKeyframes = globalMode ;
207208 if ( globalMatch ) {
208209 if ( pureMode ) {
209210 throw atrule . error ( '@keyframes :global(...) is not allowed in pure mode' ) ;
210211 }
211212 atrule . params = globalMatch [ 1 ] ;
213+ globalKeyframes = true ;
212214 } else if ( localMatch ) {
213215 atrule . params = localMatch [ 0 ] ;
216+ globalKeyframes = false ;
214217 } else if ( ! globalMode ) {
215218 atrule . params = ':local(' + atrule . params + ')' ;
216219 }
220+ atrule . walkDecls ( function ( decl ) {
221+ localizeDecl ( decl , {
222+ options : options ,
223+ global : globalKeyframes
224+ } ) ;
225+ } ) ;
217226 } else if ( atrule . nodes ) {
218227 atrule . nodes . forEach ( function ( decl ) {
219228 if ( decl . type === 'decl' ) {
Original file line number Diff line number Diff line change @@ -364,7 +364,10 @@ var tests = [
364364 ':global .b { background: url(image.png); }\n' +
365365 '.c { background: url("./image.png"); }\n' +
366366 '@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"); } }' ,
368371 options : {
369372 rewriteUrl : function ( global , url ) {
370373 var mode = global ? 'global' : 'local' ;
@@ -375,7 +378,10 @@ var tests = [
375378 '.b { background: url((global\\)image.png\\\"global\\\"); }\n' +
376379 ':local(.c) { background: url(\"(local)./image.png\\\"local\\\"\"); }\n' +
377380 '@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\\""); } }'
379385 } ,
380386 {
381387 should : 'not crash on atrule without nodes' ,
You can’t perform that action at this time.
0 commit comments