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

Fixed the loading of link element source #1185

Merged

Conversation

tomvanenckevort
Copy link
Contributor

@tomvanenckevort tomvanenckevort commented Mar 20, 2024

Types of Changes

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

This is a fix for #1184

The issue was that the _relation variable was only set during the SetupElement method. But when adding a new link element the rel attribute is often not set at this point. So if rel and href are set after creation it will never call _relation?.LoadAsync(), and therefore the resource loader won't kick in.

Changes:

  • Updated HtmlLinkElement to make sure that it attempts to load the relation when either the rel, href attributes have changed, or when the parent has changed (i.e. when it's added to the document). I took inspiration from the HtmlScriptElement where something similar happens.
  • Updated DefaultAttributeObserver to trigger the new UpdateRel method when the rel attribute changes.
  • Added a new unit test to prove that newly added links now trigger the right resource loader.

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@FlorianRappl FlorianRappl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks!

@FlorianRappl FlorianRappl added this to the 1.2.0 milestone Mar 20, 2024
@FlorianRappl FlorianRappl linked an issue Mar 20, 2024 that may be closed by this pull request
5 tasks
@FlorianRappl FlorianRappl merged commit 8aceda9 into AngleSharp:devel Mar 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link element source not loaded when element is appended to document
3 participants