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
38 changes: 37 additions & 1 deletion lib/rules/autocomplete-a11y-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,50 @@ function nodeIsASearchFunctionality(actualNode, currLevel = 0, maxLevels = 4) {
return currentLevelSearch(actualNode, currLevel);
}

function quantityField(node) {
const keywords = [
'qty',
'quantity',
'quantities',
'km',
'kilometer',
'drive',
'code',
'mileage',
'power',
'fuel'
];
const attributes = [
'name',
'id',
'title',
'placeholder',
'aria-label',
'data-label',
'data-title',
'data-placeholder',
'role'
];
return attributes.some(attr => {
if (node.hasAttribute(attr)) {
const value = node.getAttribute(attr).toLowerCase();
return keywords.some(
keyword => value && value.includes(keyword.toLowerCase())
);
}
return false;
});
}

function autocompleteA11yMatches(node, virtualNode) {
const a11yEngineFlag = true;
/* the flag is used to tell autocomplete matcher that it is being called
by a11y-engine and thus bypass an if block
The second condition is to check we are not matching with search functionality */
return (
autocompleteMatches(node, virtualNode, a11yEngineFlag) &&
!nodeIsASearchFunctionality(node)
!nodeIsASearchFunctionality(node) &&
!quantityField(node)
);
}

Expand Down
Loading