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

Bug in isElementOrAncestorDisabled? #653

Open
gillesbouvier-qz opened this issue Nov 8, 2024 · 0 comments
Open

Bug in isElementOrAncestorDisabled? #653

gillesbouvier-qz opened this issue Nov 8, 2024 · 0 comments

Comments

@gillesbouvier-qz
Copy link

gillesbouvier-qz commented Nov 8, 2024

I believe there may be a bug in isElementOrAncestorDisabled:
https://github.com/testing-library/jest-dom/blob/918b6fbcde10d4409ee8f05c6e4eecbe96a72b7a/src/to-be-disabled.js#L64C10-L64C37

and the function should be written like this instead:

function isElementOrAncestorDisabled(element) {
  return (
    canElementBeDisabled(element) &&
    (isElementDisabled(element) || (!element.hasAttribute('disabled') && isAncestorDisabled(element)))
  )
}

From: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
If this attribute is not specified, the control inherits its setting from the containing element

Before checking the parent, the function should be checking that the attribute is not specified on the element.

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

No branches or pull requests

1 participant