How does Mending work?

Items that have the Mending enchantment that are in the relevant inventory slots (feet, legs, chest, helmet, mainhand, and offhand) will be pooled together, and one will be randomly chosen to receive the repair.

There is no bias towards any particular slot, nor will equipment be ignored if already at full durability (in which case, the entire operation cancels and the experience goes to the player, rather than going to a different item). Therefore, if you have a particular item you want to repair, you will need to ensure you do not have any items with the Mending enchantment in other slots.