diff --git a/src/AngleSharp.Css.Tests/Styling/CssSheet.cs b/src/AngleSharp.Css.Tests/Styling/CssSheet.cs index 26a37a8..cf2d448 100644 --- a/src/AngleSharp.Css.Tests/Styling/CssSheet.cs +++ b/src/AngleSharp.Css.Tests/Styling/CssSheet.cs @@ -89,6 +89,76 @@ public void CssSheetSerializeBorder1pxSolidWithColor() Assert.AreEqual(expected, cssText); } + [Test] + public void CssSheetSerializeBorderSideThenBorderAll1() + { + var cssSrc = "#rule1 { border-top: none; border: 1px solid #BBCCEB }"; + var expected = "#rule1 { border: 1px solid rgba(187, 204, 235, 1) }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + + [Test] + public void CssSheetSerializeBorderSideThenBorderAll2() + { + var cssSrc = "#rule1 { border-top: none !important; border: 1px solid #BBCCEB }"; + var expected = "#rule1 { border-top: none !important; border-right: 1px solid rgba(187, 204, 235, 1); border-bottom: 1px solid rgba(187, 204, 235, 1); border-left: 1px solid rgba(187, 204, 235, 1) }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + + [Test] + public void CssSheetSerializeBorderSideThenBorderAll3() + { + var cssSrc = "#rule1 { border-top: none; border: 1px solid #BBCCEB !important }"; + var expected = "#rule1 { border: 1px solid rgba(187, 204, 235, 1) !important }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + + [Test] + public void CssSheetSerializeBorderSideThenBorderAll4() + { + var cssSrc = "#rule1 { border-top: none !important; border: 1px solid #BBCCEB !important }"; + var expected = "#rule1 { border: 1px solid rgba(187, 204, 235, 1) !important }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + + [Test] + public void CssSheetSerializeBorderAllThenBorderSide1() + { + var cssSrc = "#rule1 { border: 1px solid #BBCCEB !important; border-top: none }"; + var expected = "#rule1 { border: 1px solid rgba(187, 204, 235, 1) !important }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + + [Test] + public void CssSheetSerializeBorderAllThenBorderSide2() + { + var cssSrc = "#rule1 { border: 1px solid #BBCCEB; border-top: none !important }"; + var expected = "#rule1 { border-top: none !important; border-right: 1px solid rgba(187, 204, 235, 1); border-bottom: 1px solid rgba(187, 204, 235, 1); border-left: 1px solid rgba(187, 204, 235, 1) }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + + [Test] + public void CssSheetSerializeBorderAllThenBorderSide3() + { + var cssSrc = "#rule1 { border: 1px solid #BBCCEB !important; border-top: none !important }"; + var expected = "#rule1 { border-top: none !important; border-right: 1px solid rgba(187, 204, 235, 1) !important; border-bottom: 1px solid rgba(187, 204, 235, 1) !important; border-left: 1px solid rgba(187, 204, 235, 1) !important }"; + var stylesheet = ParseStyleSheet(cssSrc); + var cssText = stylesheet.ToCss(); + Assert.AreEqual(expected, cssText); + } + [Test] public void CssSheetSerializeBackgroundWithUrlPositionRepeatX() { diff --git a/src/AngleSharp.Css/Values/Multiples/CssPeriodicValue.cs b/src/AngleSharp.Css/Values/Multiples/CssPeriodicValue.cs index debfc48..f828861 100644 --- a/src/AngleSharp.Css/Values/Multiples/CssPeriodicValue.cs +++ b/src/AngleSharp.Css/Values/Multiples/CssPeriodicValue.cs @@ -61,7 +61,14 @@ public String CssText for (var i = 0; i < l; i++) { - parts[i] = _values[i].CssText; + var value = _values[i]; + + if (value is null) + { + return String.Empty; + } + + parts[i] = value.CssText; } if (l == 4 && parts[3].Is(parts[1]))