Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/queries/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ function makeRoleSelector(role, exact, customNormalizer) {
const explicitRoleSelector =
exact && !customNormalizer ? `*[role~="${role}"]` : '*[role]'

const roleRelations = roleElements.get(role)
const implicitRoleSelectors =
roleRelations && new Set(Array.from(roleRelations).map(({name}) => name))
const roleRelations = roleElements.get(role) ?? new Set()
const implicitRoleSelectors = new Set(
Array.from(roleRelations).map(({name}) => name),
)

return [explicitRoleSelector, ...(implicitRoleSelectors ?? [])].join(',')
// Current transpilation config sometimes assumes `...` is always applied to arrays.
// `...` is equivalent to `Array.prototype.concat` for arrays.
// If you replace this code with `[explicitRoleSelector, ...implicitRoleSelectors]`, make sure every transpilation target retains the `...` in favor of `Array.prototype.concat`.
return [explicitRoleSelector]
.concat(Array.from(implicitRoleSelectors))
.join(',')
}

const getMultipleError = (c, role, {name} = {}) => {
Expand Down