From 8205cf86f650b57695defe03b1643999d969a25e Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Fri, 19 Jan 2024 01:26:13 +0100 Subject: [PATCH] Added extra API method for computing style --- src/AngleSharp.Css/Extensions/CssOmExtensions.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/AngleSharp.Css/Extensions/CssOmExtensions.cs b/src/AngleSharp.Css/Extensions/CssOmExtensions.cs index 56394d1..2867ec3 100644 --- a/src/AngleSharp.Css/Extensions/CssOmExtensions.cs +++ b/src/AngleSharp.Css/Extensions/CssOmExtensions.cs @@ -2,6 +2,7 @@ namespace AngleSharp.Css.Dom { using AngleSharp.Css.Parser; using AngleSharp.Css.Values; + using AngleSharp.Dom; using AngleSharp.Text; using System; using System.Linq; @@ -11,6 +12,18 @@ namespace AngleSharp.Css.Dom /// public static class CssOmExtensions { + /// + /// Gets the computed style of the element. + /// + /// The element to compute the style for. + /// The optional pseudo selector to use. + /// The computed style of the element. + public static ICssStyleDeclaration ComputeStyle(this IElement element, String pseudo = null) + { + var window = element?.Owner?.DefaultView; + return window?.GetComputedStyle(element, pseudo); + } + /// /// Gets the style rule with the provided selector text. ///