Skip to content

Commit 8205cf8

Browse files
committed
Added extra API method for computing style
1 parent d856b31 commit 8205cf8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/AngleSharp.Css/Extensions/CssOmExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace AngleSharp.Css.Dom
22
{
33
using AngleSharp.Css.Parser;
44
using AngleSharp.Css.Values;
5+
using AngleSharp.Dom;
56
using AngleSharp.Text;
67
using System;
78
using System.Linq;
@@ -11,6 +12,18 @@ namespace AngleSharp.Css.Dom
1112
/// </summary>
1213
public static class CssOmExtensions
1314
{
15+
/// <summary>
16+
/// Gets the computed style of the element.
17+
/// </summary>
18+
/// <param name="element">The element to compute the style for.</param>
19+
/// <param name="pseudo">The optional pseudo selector to use.</param>
20+
/// <returns>The computed style of the element.</returns>
21+
public static ICssStyleDeclaration ComputeStyle(this IElement element, String pseudo = null)
22+
{
23+
var window = element?.Owner?.DefaultView;
24+
return window?.GetComputedStyle(element, pseudo);
25+
}
26+
1427
/// <summary>
1528
/// Gets the style rule with the provided selector text.
1629
/// </summary>

0 commit comments

Comments
 (0)