From e3b416b32b00df426a5122109a6586e0146dfdcc Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Wed, 14 Jan 2026 11:28:24 +0100 Subject: [PATCH] Consume '/' in background declaration (fixes #165) --- .../Declarations/CssBackgroundProperty.cs | 12 ++++++++++++ .../Declarations/BackgroundDeclaration.cs | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/AngleSharp.Css.Tests/Declarations/CssBackgroundProperty.cs b/src/AngleSharp.Css.Tests/Declarations/CssBackgroundProperty.cs index 03d9da7c..5ba99278 100644 --- a/src/AngleSharp.Css.Tests/Declarations/CssBackgroundProperty.cs +++ b/src/AngleSharp.Css.Tests/Declarations/CssBackgroundProperty.cs @@ -731,6 +731,18 @@ public void CssBackgroundImageNotParsed_Issue66() var expected = "linear-gradient(0deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 1), rgba(248, 248, 248, 1), rgba(238, 238, 238, 1))"; Assert.AreEqual(expected, property.Value); } + + [Test] + public void CssBackgroundPositionSlashSizeLegal() + { + var snippet = "background: center / cover"; + var property = ParseDeclaration(snippet); + Assert.AreEqual("background", property.Name); + Assert.IsFalse(property.IsImportant); + Assert.IsFalse(property.IsInherited); + Assert.IsTrue(property.HasValue); + Assert.AreEqual("center / cover", property.Value); + } } } diff --git a/src/AngleSharp.Css/Declarations/BackgroundDeclaration.cs b/src/AngleSharp.Css/Declarations/BackgroundDeclaration.cs index 985f23a8..cd6d373a 100644 --- a/src/AngleSharp.Css/Declarations/BackgroundDeclaration.cs +++ b/src/AngleSharp.Css/Declarations/BackgroundDeclaration.cs @@ -126,6 +126,7 @@ public ICssValue Convert(StringSource source) if (c == Symbols.Solidus && size == null) { + c = source.Next(); c = source.SkipSpacesAndComments(); size = source.ParseSize(); c = source.SkipSpacesAndComments(); @@ -230,7 +231,7 @@ public ICssValue[] Split(ICssValue value) return null; } - + private static ICssValue CreateLayers(CssListValue image, CssListValue attachment, CssListValue clip, CssListValue position, CssListValue origin, CssListValue repeat, CssListValue size) { var count = GetCount(image, attachment, clip, position, size, repeat, origin);