Skip to content
Merged
Changes from 1 commit
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
40 changes: 39 additions & 1 deletion lib/rules/autocomplete-a11y-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,52 @@ 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'
];
for (const attr of attributes) {
if (node.hasAttribute(attr)) {
const value = node.getAttribute(attr).toLowerCase();
for (const keyword of keywords) {
if (value && value.includes(keyword.toLowerCase())) {
return true;
}
}
}
}
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