Skip to content

Bug in isElementOrAncestorDisabled? #653

@gillesbouvier-qz

Description

@gillesbouvier-qz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions