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

Add support for HTMLButtonElement. #581

Merged
merged 1 commit into from Oct 6, 2022

Conversation

fsoikin
Copy link
Contributor

@fsoikin fsoikin commented Sep 15, 2022

When writing some tests, I noticed this:

const el = document.createElement("button")
el.setAttribute("disabled", "")
console.log(el.disabled)  // <-- Prints "undefined"

In a real browser, the last line would print out true. Checked in Chrome and FireFox.

After digging a bit, I realized that happy-dom uses the generic HTMLElement to represent a <button>, which doesn't translate between standard button attributes and properties.

This PR adds a HTMLButtonElement class and makes it translate some (not all) of the properties - specifically, value, disabled, and type.

Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

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

Looks good! ⭐ Just some minor things.

@capricorn86
Copy link
Owner

Thank you for contributing @fsoikin! 🙂

Sorry for not looking into this PR earlier. There has been a lot in my private and work life.

fsoikin added a commit to fsoikin/happy-dom that referenced this pull request Oct 6, 2022
Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

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

Great work ⭐

@capricorn86 capricorn86 merged commit 4033a53 into capricorn86:master Oct 6, 2022
rudywaltz pushed a commit to rudywaltz/happy-dom that referenced this pull request Oct 7, 2022
rudywaltz pushed a commit to rudywaltz/happy-dom that referenced this pull request Oct 7, 2022
rudywaltz pushed a commit to rudywaltz/happy-dom that referenced this pull request Oct 7, 2022
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.

None yet

2 participants