Skip to content
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

#1212 CssSelect fails when there is no html tag #1290

Merged
merged 3 commits into from
Jan 7, 2020

Conversation

robinwyss
Copy link
Contributor

Fix for #1212

When calling CssSelect on an HtmlDocument, it first selects the html tag and applies the selector to that to find matching descendants. But if the HtmlDocument doesn't have an html tag this fails and according to the HTML Specificaton this is valid.
I changed the implementation of CssSelect(doc:HtmlDocument, selector) from doc.Html() to doc.Elements() in order to apply the selector to all the root tags of the document. If the root tag is html, then it will work as before, but now it will also work if you have a page that omits it and therefore has multiple root tags, like for example:

 <head>
    <title>Hello</title>
  </head>
  <body>
    <p>Welcome to this example.</p>
  </body>

Please let me know if there are any issues with this fix or if there is anything I can improve.

@dsyme dsyme merged commit 9716da5 into fsprojects:master Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants