AngleSharp / AngleSharp.Css

:angel: Library to enable support for cascading stylesheets in AngleSharp.
https://anglesharp.github.io
MIT License
72 stars 34 forks source link

Some link tags cannot be casted to ILinkStyle #149

Closed gandolh closed 9 months ago

gandolh commented 1 year ago

Bug Report

Description

document.GetStyleSheets().OfType() has a problem with fetching all the css resources. I tried to fetch all the CSS from a website and some link tags couldn't be found by document.GetStyleSheets().OfType<ICssStyleSheet>(). I tried to get all the links tag that has an rel="stylesheet" and exclude those found by GetStyleSheets. In the end there was one link tag that couldn't be casted to ILinkStyle (so it was skipped by GetStyleSheets) and couldn't get the ICssStyleSheet object from it. I solved this by manually fetching with .Net HttpClient the css resource using the href tag but this seems unoptimal.

Steps to Reproduce

Minimal reproducable code: https://gist.github.com/gandolh/a810158fc79ccbe476e99a600ca1fd1b

FlorianRappl commented 9 months ago

Sorry I don't see a real MWE code to reproduce this. Examples that work with an external URL are not considered valid, as they might change / might already have changed / do a lot of things which might be unnecessary for the reproduction.

If you can show some code / what the issue is then we can maybe help you.

Also, I get the same results / no different sheets running your code:

image

There are 2 style sheets and both are there. So it's totally fine.