jest-dom icon indicating copy to clipboard operation
jest-dom copied to clipboard

Bug in `isElementOrAncestorDisabled`?

Open gillesbouvier-qz opened this issue 1 year ago • 0 comments

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.

gillesbouvier-qz avatar Nov 08 '24 03:11 gillesbouvier-qz