Skip to content

Commit

Permalink
Updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Apr 23, 2021
1 parent 5f1c008 commit 8f959a7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Released on Thursday, April 22 2021.

- Added `fill` declaration (#59)
- Added support for legacy `linear-gradient` syntax (#66)
- Fixed parsing of `background: none` (#65)
- Fixed issues with brackets being removed for `calc` expressions (#67)
- Fixed issue throwing in `grid-template: none` serializations (#63, #68)
Expand Down
12 changes: 12 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssBackgroundProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,5 +696,17 @@ public void CssBackgroundImageLinearGradientLegal()
var expected = "linear-gradient(90deg, rgba(255, 0, 0, 1), rgba(0, 0, 255, 1))";
Assert.AreEqual(expected, property.Value);
}

[Test]
public void CssBackgroundImageNotParsed_Issue66()
{
var source = "background-image: linear-gradient(top,#FFFFFF,#FFFFFF,#f8f8f8,#eeeeee)";
var property = ParseDeclaration(source);
Assert.IsTrue(property.HasValue);

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);
}
}
}

11 changes: 3 additions & 8 deletions src/AngleSharp.Css/AngleSharp.Css.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>AngleSharp.Css</AssemblyName>
<RootNamespace>AngleSharp.Css</RootNamespace>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard1.3;netstandard2.0;net46;net461;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard2.0;net46;net461;net472</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -24,11 +24,6 @@
<PackageReference Include="AngleSharp" Version="0.15.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<DelaySign>false</DelaySign>
</PropertyGroup>
Expand Down
74 changes: 41 additions & 33 deletions src/AngleSharp.Css/Parser/Micro/GradientParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,10 @@ public static ICssGradientFunctionValue ParseGradient(this StringSource source)
var pos = source.Index;
var ident = source.ParseIdent();

if (ident != null)
if (ident != null && source.Current == Symbols.RoundBracketOpen && GradientFunctions.TryGetValue(ident, out var function))
{
if (source.Current == Symbols.RoundBracketOpen)
{
var function = default(Func<StringSource, ICssGradientFunctionValue>);

if (GradientFunctions.TryGetValue(ident, out function))
{
source.SkipCurrentAndSpaces();
return function.Invoke(source);
}
}
source.SkipCurrentAndSpaces();
return function.Invoke(source);
}

source.BackTo(pos);
Expand Down Expand Up @@ -181,38 +173,54 @@ private static ICssValue ParseLinearAngle(StringSource source)
{
if (source.IsIdentifier(CssKeywords.To))
{
var angle = Angle.Zero;
source.SkipSpacesAndComments();
var a = source.ParseIdent();
source.SkipSpacesAndComments();
var b = source.ParseIdent();
var keyword = default(String);

if (a != null && b != null)
{
if (a.IsOneOf(CssKeywords.Top, CssKeywords.Bottom))
{
var t = b;
b = a;
a = t;
}
return ParseLinearAngleKeywords(source);
}
else
{
// This is for backwards compatibility. Usually only "to" syntax is supported.
var pos = source.Index;
var test = source.ParseIdent();
source.BackTo(pos);

keyword = String.Concat(a, " ", b);
}
else if (a != null)
if (test != null && Map.GradientAngles.ContainsKey(test))
{
keyword = a;
return ParseLinearAngleKeywords(source);
}
}

return source.ParseAngleOrCalc();
}

if (keyword != null && Map.GradientAngles.TryGetValue(keyword, out angle))
private static ICssValue ParseLinearAngleKeywords(StringSource source)
{
var a = source.ParseIdent();
source.SkipSpacesAndComments();
var b = source.ParseIdent();
var keyword = default(String);

if (a != null && b != null)
{
if (a.IsOneOf(CssKeywords.Top, CssKeywords.Bottom))
{
return angle;
var t = b;
b = a;
a = t;
}

return null;
keyword = String.Concat(a, " ", b);
}
else if (a != null)
{
keyword = a;
}

return source.ParseAngleOrCalc();
if (keyword != null && Map.GradientAngles.TryGetValue(keyword, out var angle))
{
return angle;
}

return null;
}

private static RadialOptions? ParseRadialOptions(StringSource source)
Expand Down

0 comments on commit 8f959a7

Please sign in to comment.