File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -907,6 +907,7 @@ mod tests {
907907 minify_test ( ".foo { background-position: bottom right }" , ".foo{background-position:100% 100%}" ) ;
908908
909909 minify_test ( ".foo { background: url('img-sprite.png') no-repeat bottom right }" , ".foo{background:url(img-sprite.png) 100% 100% no-repeat}" ) ;
910+ minify_test ( ".foo { background: transparent }" , ".foo{background:#0000}" ) ;
910911 }
911912
912913 #[ test]
Original file line number Diff line number Diff line change @@ -290,23 +290,23 @@ impl Parse for Background {
290290
291291impl ToCss for Background {
292292 fn to_css < W > ( & self , dest : & mut Printer < W > ) -> std:: fmt:: Result where W : std:: fmt:: Write {
293- let mut needs_space = false ;
293+ let mut has_output = false ;
294294
295295 if self . color != CssColor :: default ( ) {
296296 self . color . to_css ( dest) ?;
297- needs_space = true ;
297+ has_output = true ;
298298 }
299299
300300 if self . image != Image :: default ( ) {
301- if needs_space {
301+ if has_output {
302302 dest. write_str ( " " ) ?;
303303 }
304304 self . image . to_css ( dest) ?;
305- needs_space = true ;
305+ has_output = true ;
306306 }
307307
308308 if self . position != Position :: default ( ) || self . size != BackgroundSize :: default ( ) {
309- if needs_space {
309+ if has_output {
310310 dest. write_str ( " " ) ?;
311311 }
312312 self . position . to_css ( dest) ?;
@@ -316,29 +316,29 @@ impl ToCss for Background {
316316 self . size . to_css ( dest) ?;
317317 }
318318
319- needs_space = true ;
319+ has_output = true ;
320320 }
321321
322322 if self . repeat != BackgroundRepeat :: default ( ) {
323- if needs_space {
323+ if has_output {
324324 dest. write_str ( " " ) ?;
325325 }
326326
327327 self . repeat . to_css ( dest) ?;
328- needs_space = true ;
328+ has_output = true ;
329329 }
330330
331331 if self . attachment != BackgroundAttachment :: default ( ) {
332- if needs_space {
332+ if has_output {
333333 dest. write_str ( " " ) ?;
334334 }
335335
336336 self . attachment . to_css ( dest) ?;
337- needs_space = true ;
337+ has_output = true ;
338338 }
339339
340340 if self . origin != BackgroundBox :: PaddingBox || self . clip != BackgroundBox :: BorderBox {
341- if needs_space {
341+ if has_output {
342342 dest. write_str ( " " ) ?;
343343 }
344344
@@ -348,6 +348,13 @@ impl ToCss for Background {
348348 dest. write_str ( " " ) ?;
349349 self . clip . to_css ( dest) ?;
350350 }
351+
352+ has_output = true ;
353+ }
354+
355+ // If nothing was output, then this is the initial value, e.g. background: transparent
356+ if !has_output {
357+ self . color . to_css ( dest) ?;
351358 }
352359
353360 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments