Consider making UseFocus::attribute
an opaque type.
#886
Labels
internal impovement👍
Internal code improvements
UseFocus::attribute
an opaque type.
#886
Currently the user can pass their own accesskit ID into
a11y_id
, which is intended forUseFocus
at the moment due to having all types public:This is bad, because it allows the user to pass a duplicate accessibility ID which can mess up the tree in unexpected ways. Generally accesskit node IDs shouldn't be exposed to users at all, since they can't know the current value of the ID counter (thus allowing for overlap with any given
u64
). To fix this, we can makeUseFocus::attribute
return an opaque wrapper type overaccesskit::NodeId
with theNodeId
itself not publicly exposed, making the only way to generate it being through ause_focus
hook.This will enforce the invariant that accessibility IDs must first go through the
AccessibilityGenerator
counter.The text was updated successfully, but these errors were encountered: