Skip to content

Commit

Permalink
fix: add custom element support to toBeDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
astorije committed May 21, 2021
1 parent c816955 commit e41eb9d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/to-be-disabled.js
Expand Up @@ -36,8 +36,17 @@ function isElementDisabledByParent(element, parent) {
)
}

function isCustomElement(tag) {
return tag.includes('-')
}

/*
* Only certain form elements and all custom elements can actually be disabled:
* https://html.spec.whatwg.org/multipage/semantics-other.html#disabled-elements
*/
function canElementBeDisabled(element) {
return FORM_TAGS.includes(getTag(element))
const tag = getTag(element)
return FORM_TAGS.includes(tag) || isCustomElement(tag)
}

function isElementDisabled(element) {
Expand Down

0 comments on commit e41eb9d

Please sign in to comment.