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

Added Image constructor support #94

Merged

Conversation

tomvanenckevort
Copy link
Contributor

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 PR adds support for the Image constructor as described here.

Since this constructor does not directly link to the HTMLImageElement constructor, I have added a new "constructor function" way of adding constructors to the Window object:

  • Added DomConstructorFunctionInstance which stores a reference to the constructor function and calls it when Jint calls the Construct function.
  • Added DomConstructorFunctionAttribute to decorate any methods that need to be treated as a constructor function.
  • Added methods in the EngineExtensions, EngineInstance and CreatorCache to find any decorated constructor functions and add them to the Window object.
  • Added new extension method to WindowExtensions which handles the Image constructor call and returns a new IHtmlImageElement instance.
  • Added unit test to test new Image constructor.

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 v1.0 milestone Mar 25, 2024
@FlorianRappl FlorianRappl merged commit e8de221 into AngleSharp:devel Mar 25, 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.

2 participants