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

Link element source not loaded when element is appended to document #1184

Closed
5 tasks done
tomvanenckevort opened this issue Mar 20, 2024 · 0 comments · Fixed by #1185
Closed
5 tasks done

Link element source not loaded when element is appended to document #1184

tomvanenckevort opened this issue Mar 20, 2024 · 0 comments · Fixed by #1185
Milestone

Comments

@tomvanenckevort
Copy link
Contributor

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?

Description

When setting up the BrowsingContext with the default resource loader and loading an HTML document it loads any link elements with stylesheets just fine. But when appending any new link elements to the document they do not get loaded as expected.

Steps to Reproduce

var config = Configuration.Default
                .WithCss()
                .WithDefaultLoader(new LoaderOptions() { IsResourceLoadingEnabled = true });

var html = @"<!doctype html><body></body>";

var document = BrowsingContext.New(config).OpenAsync(m => m.Content(html));

var link = document.CreateElement("link");
link.SetAttribute(AttributeNames.Rel, "stylesheet");
link.SetAttribute(AttributeNames.Href, "/mock-stylesheet.css");

document.Body.AppendChild(link);

Expected Behavior

The newly added link element's source should be loaded by the default resource loader (and in this case the CSS stylesheet should be parsed).

Actual Behavior

The link element is added to the document, but no request is made for the link's href URL.

Possible Solution / Known Workarounds

I have a PR ready for this with a fix.

@FlorianRappl FlorianRappl added this to the 1.2.0 milestone Mar 20, 2024
@FlorianRappl FlorianRappl linked a pull request Mar 20, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants