Skip to content

StyleCollectionExtensions.SortBySpecificity does not account for null selector. #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 of 5 tasks
The-Nutty opened this issue Apr 3, 2020 · 3 comments
Closed
4 of 5 tasks

Comments

@The-Nutty
Copy link
Contributor

The-Nutty commented Apr 3, 2020

Bug Report

I have observed instances where ICssStyleRule.Selector is null. This causes StyleCollectionExtensions.SortBySpecificity to throw a null reference exception.

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Possible Solution

I unfortunately dont have the raw HTML that caused this issue but i have confirmed the following change does fix the issue.

            rules.Where(m => m.Selector?.Match(element) ?? false).OrderBy(m => m.Selector.Specificity);

Would you accept a PR for this solution?

@The-Nutty The-Nutty added the bug label Apr 3, 2020
@FlorianRappl
Copy link
Contributor

Yeah definitely!

Much appreciated 👍!

@FlorianRappl
Copy link
Contributor

I already pushed it! Thanks for investigating this - indeed it was an issue and the fix works like a charme! 🍻

Landed in devel and the preview.

@The-Nutty
Copy link
Contributor Author

Brilliant thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants