-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Summary
querySelectorAllExt can return [null] which violates the documented return type of findAttributeTargets: (Node|Window)[]. This has upstream effects on methods like disableElements, which iterate through a collection of elements returned by findAttributeTargets, expecting each to be not null.
function findAttributeTargets(elt, attrName) {
const attrTarget = getClosestAttributeValue(elt, attrName)
if (attrTarget) {
if (attrTarget === 'this') {
return [findThisElement(elt, attrName)]
} else {
const result = querySelectorAllExt(elt, attrTarget) // <-- This can return [null]
if (result.length === 0) {
logError('The selector "' + attrTarget + '" on ' + attrName + ' returned no matches!')
return [DUMMY_ELT]
} else {
return result
}
}
}
}Context
In my application, this happens when the elt passed in to findAttributeTargets has no children and the attrTarget would yield no results. The attrName in my context is hx-disabled-elt.
Workaround
In my setup, the inherited hx-disabled-elt was causing the failed lookup. I explicitly set the hx-disabled-elt to a query selector that would return results to unblock myself.
Metadata
Metadata
Assignees
Labels
No labels