[X] Are you running the latest version of AngleSharp.Css?
[X] Did you check the FAQs to see if that helps you?
[X] Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Xml for Xml support)
[X] Did you perform a search in the issues?
Description
AngleSharp fails to compute style for <div style=""></div> with the latest preview 1.0.0-beta.122
System.NullReferenceException: Object reference not set to an instance of an object.
at AngleSharp.Css.Dom.CssStyleDeclaration.ChangeDeclarations(IEnumerable`1 decls, Predicate`1 defaultSkip, Func`3 removeExisting)
at AngleSharp.Css.Dom.CssStyleDeclaration.SetDeclarations(IEnumerable`1 decls)
at AngleSharp.Css.StyleCollectionExtensions.ComputeCascadedStyle(IStyleCollection styles, IElement element, ICssStyleDeclaration parent)
at AngleSharp.Css.StyleCollectionExtensions.ComputeDeclarations(IStyleCollection styles, IElement element, String pseudoSelector)
at AngleSharp.Dom.WindowExtensions.GetComputedStyle(IWindow window, IElement element, String pseudo)
at Program.<Main>$(String[] args) in D:\source\ConsoleApp4\ConsoleApp4\Program.cs:line 16
at Program.<Main>(String[] args)
using AngleSharp.Css;
using AngleSharp;
using AngleSharp.Io;
using AngleSharp.Dom;
var configuration = new AngleSharp.Configuration()
.WithDefaultLoader()
.WithRenderDevice(new DefaultRenderDevice() { ViewPortHeight = 100, ViewPortWidth = 100 });
var context = BrowsingContext.New(configuration);
using var response = VirtualResponse.Create(request => request.Content("""
<div style="transform-origin: bottom"></div>
"""));
var document = await context.OpenAsync(response, CancellationToken.None);
var element = document.QuerySelector("div");
var style = document.DefaultView.GetComputedStyle(element); // throw NRE
Prerequisites
AngleSharp.Xml
for Xml support)Description
AngleSharp fails to compute style for
<div style=""></div>
with the latest preview1.0.0-beta.122
Steps to Reproduce
Expected Behavior
No exception
Actual Behavior
It throws a NullReferenceException
Possible Solution / Known Workarounds
No response