File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
AngleSharp.Css.Tests/Extensions Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ namespace AngleSharp.Css.Tests.Extensions
4
4
using AngleSharp . Dom ;
5
5
using NUnit . Framework ;
6
6
using System . Text ;
7
+ using System . Threading . Tasks ;
7
8
using static CssConstructionFunctions ;
8
9
9
10
[ TestFixture ]
@@ -277,5 +278,16 @@ public void GetCascadedValueOfTextTransformFromElementStyle()
277
278
Assert . IsNotNull ( styleNormal ) ;
278
279
Assert . AreEqual ( "uppercase" , styleNormal . GetTextTransform ( ) ) ;
279
280
}
281
+
282
+ [ Test ]
283
+ public async Task NullSelectorStillWorks_Issue52 ( )
284
+ {
285
+ var sheet = ParseStyleSheet ( "a {}" ) ;
286
+ var document = await sheet . Context . OpenAsync ( res => res . Content ( "<body></body>" ) ) ;
287
+ sheet . Add ( new CssStyleRule ( sheet ) ) ;
288
+ var sc = new StyleCollection ( new [ ] { sheet } , new DefaultRenderDevice ( ) ) ;
289
+ var decl = sc . ComputeCascadedStyle ( document . Body ) ;
290
+ Assert . IsNotNull ( decl ) ;
291
+ }
280
292
}
281
293
}
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ public static ICssStyleDeclaration ComputeCascadedStyle(this StyleCollection sty
103
103
#region Helpers
104
104
105
105
private static IEnumerable < ICssStyleRule > SortBySpecificity ( this IEnumerable < ICssStyleRule > rules , IElement element ) =>
106
- rules . Where ( m => m . Selector . Match ( element ) ) . OrderBy ( m => m . Selector . Specificity ) ;
106
+ rules . Where ( m => m . Selector ? . Match ( element ) ?? false ) . OrderBy ( m => m . Selector . Specificity ) ;
107
107
108
108
#endregion
109
109
}
You can’t perform that action at this time.
0 commit comments