Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/ExCSS.Tests/PropertyTests/BackgroundProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,5 +736,26 @@ public void BackgroundImageDataUrlLegal()
Assert.True(concrete.HasValue);
Assert.Equal("url(\"" + url + "\")", concrete.Value);
}

[Fact]
public void BackgroundMultipleLayersExportCommaSeparatedLonghands()
{
// Each comma-separated layer must stay its own layer when the shorthand is exported to the
// longhands; joining them with whitespace produces one invalid layer instead of two valid ones.
var style = ParseDeclarations("background: url(a.png) no-repeat, url(b.png) repeat");

Assert.Equal("url(\"a.png\"), url(\"b.png\")", style.BackgroundImage);
Assert.Equal("no-repeat, repeat", style.BackgroundRepeat);
}

[Fact]
public void BackgroundThreeLayersExportCommaSeparatedLonghands()
{
var style = ParseDeclarations(
"background: url(a.png) no-repeat, url(b.png) repeat-x, url(c.png) repeat");

Assert.Equal("url(\"a.png\"), url(\"b.png\"), url(\"c.png\")", style.BackgroundImage);
Assert.Equal("no-repeat, repeat-x, repeat", style.BackgroundRepeat);
}
}
}
6 changes: 5 additions & 1 deletion src/ExCSS/ValueConverters/EndListValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ public TokenValue ExtractFor(string name)

if (extracted == null) continue;

if (tokens.Count > 0) tokens.Add(Token.Whitespace);
// Layers stay comma-separated when exported to a longhand, matching CssText above and
// ListValueConverter's own ExtractFor. Joining with whitespace instead ran the layers
// together: "background: url(a) no-repeat, url(b) repeat" gave a background-repeat of
// "no-repeat repeat", which is a single invalid layer rather than two valid ones.
if (tokens.Count > 0) tokens.Add(Token.Comma);

tokens.AddRange(extracted);
}
Expand Down