dequelabs / dequelabs/axe-core
`getAriaValue` returns `null` instead of `{ value: null, source: null }`
- Dominant language
- JavaScript
- Stars
- 7.5k
- Forks
- 933
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 17
Description
### Background
`commons/aria/get-aria-value.js` returns `{ value, source }` when a value is found and `null` otherwise. Because of the `null`, callers can't safely destructure — they have to guard with optional chaining, e.g. `getAriaValue(vNode, 'aria-label')?.value`, and there's no clean way to pull both `value` and `source` out in one statement.
### Proposal
Return `{ value: null, source: null }` instead of `null` when no value is found, so the result is always safely destructurable:
```js
const { value, source } = getAriaValue(vNode, 'aria-label');
```
### Considerations
- `getAriaValue` is consumed across `commons/` and `checks/`; existing callers use the `?.value` pattern, which would keep working (`{value:null}?.value` → `null`), but should be reviewed/simplified where it makes sense.
- `hasAriaValue` is the right call for pure presence checks and shouldn't change.
- #5177 adds another `null`-return path (elements not in the tree), so that case should be covered by the same shape change.
Raised by @WilcoFiers in review of #5171 (deferred there as a separate PR).
Contributor guide
Assessment
This issue has not been assessed yet.