@@ -21,18 +21,10 @@ public static ICssGradientFunctionValue ParseGradient(this StringSource source)
2121 var pos = source . Index ;
2222 var ident = source . ParseIdent ( ) ;
2323
24- if ( ident != null )
24+ if ( ident != null && source . Current == Symbols . RoundBracketOpen && GradientFunctions . TryGetValue ( ident , out var function ) )
2525 {
26- if ( source . Current == Symbols . RoundBracketOpen )
27- {
28- var function = default ( Func < StringSource , ICssGradientFunctionValue > ) ;
29-
30- if ( GradientFunctions . TryGetValue ( ident , out function ) )
31- {
32- source . SkipCurrentAndSpaces ( ) ;
33- return function . Invoke ( source ) ;
34- }
35- }
26+ source . SkipCurrentAndSpaces ( ) ;
27+ return function . Invoke ( source ) ;
3628 }
3729
3830 source . BackTo ( pos ) ;
@@ -181,38 +173,54 @@ private static ICssValue ParseLinearAngle(StringSource source)
181173 {
182174 if ( source . IsIdentifier ( CssKeywords . To ) )
183175 {
184- var angle = Angle . Zero ;
185- source . SkipSpacesAndComments ( ) ;
186- var a = source . ParseIdent ( ) ;
187176 source . SkipSpacesAndComments ( ) ;
188- var b = source . ParseIdent ( ) ;
189- var keyword = default ( String ) ;
190-
191- if ( a != null && b != null )
192- {
193- if ( a . IsOneOf ( CssKeywords . Top , CssKeywords . Bottom ) )
194- {
195- var t = b ;
196- b = a ;
197- a = t ;
198- }
177+ return ParseLinearAngleKeywords ( source ) ;
178+ }
179+ else
180+ {
181+ // This is for backwards compatibility. Usually only "to" syntax is supported.
182+ var pos = source . Index ;
183+ var test = source . ParseIdent ( ) ;
184+ source . BackTo ( pos ) ;
199185
200- keyword = String . Concat ( a , " " , b ) ;
201- }
202- else if ( a != null )
186+ if ( test != null && Map . GradientAngles . ContainsKey ( test ) )
203187 {
204- keyword = a ;
188+ return ParseLinearAngleKeywords ( source ) ;
205189 }
190+ }
191+
192+ return source . ParseAngleOrCalc ( ) ;
193+ }
206194
207- if ( keyword != null && Map . GradientAngles . TryGetValue ( keyword , out angle ) )
195+ private static ICssValue ParseLinearAngleKeywords ( StringSource source )
196+ {
197+ var a = source . ParseIdent ( ) ;
198+ source . SkipSpacesAndComments ( ) ;
199+ var b = source . ParseIdent ( ) ;
200+ var keyword = default ( String ) ;
201+
202+ if ( a != null && b != null )
203+ {
204+ if ( a . IsOneOf ( CssKeywords . Top , CssKeywords . Bottom ) )
208205 {
209- return angle ;
206+ var t = b ;
207+ b = a ;
208+ a = t ;
210209 }
211210
212- return null ;
211+ keyword = String . Concat ( a , " " , b ) ;
212+ }
213+ else if ( a != null )
214+ {
215+ keyword = a ;
213216 }
214217
215- return source . ParseAngleOrCalc ( ) ;
218+ if ( keyword != null && Map . GradientAngles . TryGetValue ( keyword , out var angle ) )
219+ {
220+ return angle ;
221+ }
222+
223+ return null ;
216224 }
217225
218226 private static RadialOptions ? ParseRadialOptions ( StringSource source )
0 commit comments