Function: matchAnchors()
function matchAnchors(anchors, initialSelector): AnchorScore[];
Defined in: packages/uimatch-selector-anchors/src/matching/anchor-matcher.ts:223
Match anchors against initial selector hint Returns anchors sorted by relevance score (highest first)
Parameters
anchors
object[]
Array of available anchors
initialSelector
string
Initial selector provided by user
Returns
Sorted array of anchors with scores
Example
const anchors = [
{ id: 'button-1', hint: 'testid:submit-btn', ...otherFields },
{ id: 'button-2', hint: 'role:button', ...otherFields }
];
const matches = matchAnchors(anchors, '[data-testid="submit-btn"]');
// Returns: [
// { anchor: {...button-1}, score: 95, reasons: ['Exact testid match'] },
// { anchor: {...button-2}, score: 20, reasons: ['Component metadata'] }
// ]