Skip to content

Commit e41eb9d

Browse files
authored
fix: add custom element support to toBeDisabled
1 parent c816955 commit e41eb9d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/to-be-disabled.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ function isElementDisabledByParent(element, parent) {
3636
)
3737
}
3838

39+
function isCustomElement(tag) {
40+
return tag.includes('-')
41+
}
42+
43+
/*
44+
* Only certain form elements and all custom elements can actually be disabled:
45+
* https://html.spec.whatwg.org/multipage/semantics-other.html#disabled-elements
46+
*/
3947
function canElementBeDisabled(element) {
40-
return FORM_TAGS.includes(getTag(element))
48+
const tag = getTag(element)
49+
return FORM_TAGS.includes(tag) || isCustomElement(tag)
4150
}
4251

4352
function isElementDisabled(element) {

0 commit comments

Comments
 (0)